View previous topic :: View next topic
|
Author |
Message |
karnataka
New User
Joined: 15 Sep 2006 Posts: 20 Location: bangalore
|
|
|
|
Hi,
I am using cursor for deleting a record. Could you please tell me whats the use of "For UPdate" while declaring cursor in this case. Is this mandatory?
Thanks,
Jyothi |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest that you are not using a cursor for deleting. . .
You are using a cursor for reading. Once a row is read (for update) it can be deleted. |
|
Back to top |
|
|
karnataka
New User
Joined: 15 Sep 2006 Posts: 20 Location: bangalore
|
|
|
|
Sorry.. Dick
Do you mean to say "FOR UPDATE" clause is not mandatory for cursor , incase if cursor is using for deleting record. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Do you mean to say "FOR UPDATE" clause is not mandatory for cursor , incase if cursor is using for deleting record. |
Exactly the opposite. . .
In order to update/delete a fetched row, the row must be "held" - read FOR UPDATE.
One of the most basic concepts in every database system is that in order to update/delete data, the process must have control of that data (i.e. "held", "locked", etc). |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
"for update" is not mandatory, but it helps to detect a read-only cursor you wish to use for update. |
|
Back to top |
|
|
|