this post was submitted on 11 Oct 2023
418 points (97.9% liked)

Programming

17506 readers
32 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

"UPDATE table_name SET w = $1, x = $2, z = $4 WHERE y = $3 RETURNING *",

does not do the same as

"UPDATE table_name SET w = $1, x = $2, y = $3, z = $4 RETURNING *",

It's 2 am and my mind blanked out the WHERE, and just wanted the numbers neatly in order of 1234.

idiot.

FML.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 58 points 1 year ago (4 children)

You're not the first. You won't be the last. I'm just glad my DB of choice uses transactions by default, so I can see "rows updated: 3,258,123" and back the fuck out of it.

I genuinely believe that UPDATE and DELETE without a WHERE clause should be considered a syntax error. If you want to do all rows for some reason, it should have been something like UPDATE table SET field=value ALL.

[–] [email protected] 1 points 1 year ago (3 children)

Because I'm relatively new at this type of thing, how does that appear on the front end? I'm using a js/html front end and a jsnode backend. Would I just see a popup before I make any changes?

[–] aravindan_v 2 points 1 year ago (1 children)

If you're asking about the information about the number of rows, oracle db clients do that. For nodejs, oracle's library will provide this number in the response to a dml statement execution. So you can retrieve it in your backend code. You have to write additional code to bring this message to the front-end.

https://oracle.github.io/node-oracledb/

[–] [email protected] 1 points 1 year ago

Awesome, thanks for the info. Definitely super useful for debug mode whilst I'm fixing and tampering!

load more comments (1 replies)
load more comments (1 replies)