Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

SQL92[EXPERTS]

Name: Anonymous 2010-04-16 12:53

Hey /prog/

Is it legal to modify a table while there's a read cursor open on it? Is it defined behavior?

For example, in some pseudo-code:

result = sql("SELECT * FROM faggot_table WHERE faggot_type=5;");
for each (result) {
  if (whatever) sql("DELETE FROM faggot_table WHERE faggot_id=3;");
}

The reason I ask is because I tested with several database engines from the ENTERPRISE to the toy, and it works on some but errors out in others. So I can't use it in the general case.

However I'd like to know if it should work and some databases suck, if it shouldn't but is supported on some, or if it mustn't and it works by chance on some.

(It could work in some because they prefetch results, and maybe if they prefetch everything the cursor is already closed the moment you read the first row)

Name: Anonymous 2010-04-16 16:45

>>1
You know about cursors, so why do you want to do something stupid like that?

Name: Anonymous 2010-04-16 17:54

Legal or not you should almost never use a cursor like that. Just write the delete query differently.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List