Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 cursor update

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sharad_shanu

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jan 02, 2008 11:07 am    Post subject: DB2 cursor update
Reply with quote

Hi,

I have a small query.

Q. Consider a high transaction density environment i.e. several users simultaneously updating data.
The requirement is to select some data; then update it after its validation.

SELECT Col1
FROM Table
WHERE Col2 = :given;

Perform validation on retrieved data: Col1.

UPDATE Table
SET Col1 = :value
WHERE Col2 = :given;

What could go wrong with the above 2 SQLs executed sequentially in a program?

And how to correct it using a cursor?
HINT: FOR UPDATE OF, WHERE CURRENT OF

That's all I have. Please help me out regarding this.

Thanks,
Sharad Srivastava
Back to top
View user's profile Send private message

ahalyah

New User


Joined: 13 Dec 2007
Posts: 25
Location: india

PostPosted: Wed Jan 02, 2008 2:20 pm    Post subject:
Reply with quote

Hi,
if you use UPDATE OF clause then u can get the exclusive lock over the column and you can update it. By this time no othe person can update it untill you issue the commit.
Please correct me if i am wrong.
Back to top
View user's profile Send private message
sharad_shanu

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jan 02, 2008 2:39 pm    Post subject:
Reply with quote

Yes!...thank you.

But I am more concerned towards the first part of the query.
that is:

What could go wrong with the above 2 SQLs executed sequentially in a program?

I hope you would understand my requirement.

Thanks,
Sharad Srivastava
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Wed Jan 02, 2008 2:44 pm    Post subject:
Reply with quote

Hi Sharad,

Is this question from any question bank? If no, what happened when you have executed?

If you tell what type of problem you have faced, forum can provide possible solution.
Back to top
View user's profile Send private message
sharad_shanu

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jan 02, 2008 2:50 pm    Post subject:
Reply with quote

Hi,

This question was asked during a unit test and I was not able to anser.
That's why I am concerned about it.

Particularly the first part. (As written above)




Thanks,
Sharad Srivastava
Back to top
View user's profile Send private message
sharad_shanu

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jan 02, 2008 4:08 pm    Post subject:
Reply with quote

Can anyone answer my query??


Thanks,
Sharad Srivastava
Back to top
View user's profile Send private message
ahalyah

New User


Joined: 13 Dec 2007
Posts: 25
Location: india

PostPosted: Wed Jan 02, 2008 5:05 pm    Post subject: Reply to: DB2 cursor update
Reply with quote

Hi Sharad,
if you select the column without UPDATE OF clause then there may be chances to take exclusive access from some other during your select and update time. If somebody have taken the exclusive access then until they release it u cant update the column.
If u use it then nobody can take the access unless your process completes.
Back to top
View user's profile Send private message
sharad_shanu

New User


Joined: 03 Oct 2006
Posts: 40

PostPosted: Wed Jan 02, 2008 5:14 pm    Post subject:
Reply with quote

Ok...it seems good.

Thanks to all for help.

Regards,
Sharad Srivastava
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us