Cursors, locks, and Update [message #417899] |
Wed, 12 August 2009 01:14 |
nokheat
Messages: 2 Registered: August 2009
|
Junior Member |
|
|
hi, I would like to find what is the straight forward and best way to do this?
DECLARE
Cursor c1 IS
SELECT a set from Table_A
FOR UPDATE NOWAIT;
BEGIN
block update
UPDATE Table_B
SET blah_blah= x
WHERE
record_num IN c1
UPDATE Table_B
SET update_date= sysdate
WHERE
record_num IN c1
COMMIT and Unlock
END
|
|
|
|
Re: Cursors, locks, and Update [message #417906 is a reply to message #417901] |
Wed, 12 August 2009 01:39 |
nokheat
Messages: 2 Registered: August 2009
|
Junior Member |
|
|
best in terms of server loading in run-time, and repetitive select is to be avoided.
and i would also like to keep the updates statements as update to the whole block of records.
i am asking because i need to use a cursor to hold the results from the select, but i must not loop thought it ... another question is on the variable holding the results... would a cursor be appropriate?
|
|
|
Re: Cursors, locks, and Update [message #417908 is a reply to message #417899] |
Wed, 12 August 2009 01:40 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Do it in a single UPDATE.
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags.
Use the "Preview Message" button to verify.
Also always post your Oracle version with 4 decimals.
Regards
Michel
|
|
|