Subject | Is it safe to UPDATE a SELECT result? |
---|---|
Author | Matthias Hanft |
Post date | 2012-12-13T18:06:11Z |
Hello,
I need to change some data in every record of a customer database.
Not very fancy (SELECT until EOF, UPDATE... just as usual). But it
just came to my mind that this way I'm updating the result of a
SELECT query - is this allowed (and safe)?
What I plan to do is about this:
StartTransaction;
SELECT ID, some_other_fields FROM CUSTOMERS ORDER BY ID;
while not Select_Eof do begin
UPDATE CUSTOMERS SET some_other_fields=some_new_data
WHERE ID=current_id;
end;
Select_Close;
CommitTransaction;
I don't want to "disturb" the SELECT command by my updates. From
what I know about Firebird, I'm pretty sure that it *should* work
this way; I'm just asking to be on the *very* safe side ;)
Thank you,
-Matt
I need to change some data in every record of a customer database.
Not very fancy (SELECT until EOF, UPDATE... just as usual). But it
just came to my mind that this way I'm updating the result of a
SELECT query - is this allowed (and safe)?
What I plan to do is about this:
StartTransaction;
SELECT ID, some_other_fields FROM CUSTOMERS ORDER BY ID;
while not Select_Eof do begin
UPDATE CUSTOMERS SET some_other_fields=some_new_data
WHERE ID=current_id;
end;
Select_Close;
CommitTransaction;
I don't want to "disturb" the SELECT command by my updates. From
what I know about Firebird, I'm pretty sure that it *should* work
this way; I'm just asking to be on the *very* safe side ;)
Thank you,
-Matt