IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Is "FOR UPDATE" is neccessary while declaring Dele


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Mon Sep 06, 2010 9:42 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Sep 06, 2010 10:39 pm
Reply with quote

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
View user's profile Send private message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Mon Sep 06, 2010 11:02 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Sep 07, 2010 12:25 am
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Sep 07, 2010 4:47 pm
Reply with quote

"for update" is not mandatory, but it helps to detect a read-only cursor you wish to use for update.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Newbie Stuck on "Duplicate Datas... TSO/ISPF 5
No new posts RABBIT HOLE NEEDED - "Live"... All Other Mainframe Topics 0
No new posts Read a flat file and update DB2 table JCL & VSAM 2
No new posts how to update an ISR appl var from an... TSO/ISPF 8
Search our Forums:

Back to Top