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
 

 

Cursor giving back updated cursors

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

New User


Joined: 16 Jul 2008
Posts: 22
Location: Bangalore

PostPosted: Fri Nov 21, 2008 7:04 pm    Post subject: Cursor giving back updated cursors
Reply with quote

Hi,

I have a joined cursor with 2 tables. I am updating one of the table after fetching each record. But each time I update, my cursor is fetching the updated record once again, which I had previoulsy fetched.

Do you know how can I prevent this.

Regards
harijax
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Sun Nov 23, 2008 8:36 am    Post subject:
Reply with quote

Hello,

Is the first row being updated over and over or are multiple rows processed multiple times?
Back to top
View user's profile Send private message
harijax

New User


Joined: 16 Jul 2008
Posts: 22
Location: Bangalore

PostPosted: Mon Nov 24, 2008 8:38 am    Post subject:
Reply with quote

Hi Dick, no.. one row in updated only twice. Then it go to the 2nd row. I have a field called Version_No in the table, which I increment after every update.

Now here is how it goes. Eg I have 3 records like below, which I wanted to fetch.

Student Name Version_NO
100 AAA 2
101 BBB 1
102 CCC 3

Now I fetch the first row of No. 100 and increment and update Version_no. But after this update, my cursor is fetching again the same updated reord as

100 AAA 3

and then update it to

100 AAA 4.

But after that it correctly fetches 101 B 1.

I dont know what is the reason.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Nov 24, 2008 9:27 am    Post subject:
Reply with quote

Hello,

How is your cursor declared?
Back to top
View user's profile Send private message
harijax

New User


Joined: 16 Jul 2008
Posts: 22
Location: Bangalore

PostPosted: Mon Nov 24, 2008 9:57 am    Post subject:
Reply with quote

Hi Dick,

It is as below.

DECLARE CURSOR
SELECT STUDENT, NAME, VERSIOn_NO
WHERE
STUDENT > :ws-Student-no >> (Used for restart)
ORDER BY Student_No

For normal run
ws-Student-no = zero

For restart run
ws-student-no = Chkpt-stdent-no (for checkpoint table),
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Nov 24, 2008 10:25 am    Post subject:
Reply with quote

Hello,

Please post the code around the fetch and the update (i should have asked earlier).

Is the cursor opened/closed one time or are there multiple cursor open/close throughout the run?
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 CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts DB2 Stored Procedure - Dynamic SQL - ... GuyC DB2 2 Wed Feb 17, 2016 5:10 pm
No new posts ISREDIT - Position Cursor on the Comm... Tarique Anwer TSO/ISPF 5 Wed Feb 03, 2016 12:44 pm


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