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
 

 

WHY SQLCODE -508 occurs if COMMIT between FETCH and UPDATE?

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

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Nov 08, 2013 7:30 am    Post subject: WHY SQLCODE -508 occurs if COMMIT between FETCH and UPDATE?
Reply with quote

I found if I code COMMIT after FETCH CURSOR and before POSITIONED UPDATE CURSOR, SQLCODE -508 always occurrs when POSTIONED UPDATE CURSOR.

1. FETCH CURSOR C1
2. COMMIT
3. POSITIONE UPDATE C1 ==>SQLCODE -508 here....

Why this happens?

I have such requirement, that I should first fetch the next record and if some criteria meets, I shall issue COMMIT first before issue POSITIONED UPDATE. How should I do ?

Please kindly suggest.

Thanks very much.
Back to top
View user's profile Send private message

GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Fri Nov 08, 2013 1:31 pm    Post subject:
Reply with quote

why this happens? Because it is described as such in the manuals.
and it doesn't happen ALWAYS.
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Fri Nov 08, 2013 4:36 pm    Post subject:
Reply with quote

-508 THE CURSOR IDENTIFIED IN THE UPDATE OR DELETE STATEMENT IS NOT POSITIONED
ON A ROW OR ROWSET THAT CAN BE UPDATED OR DELETED
Explanation: The application program attempted to execute an UPDATE or DELETE WHERE CURRENT OF cursor
statement at a time when the specified cursor was not positioned on a row or rowset of the object table. The cursor
must be positioned on the row that is to be updated or deleted.
This can occur if the cursor is no longer positioned on the row because another cursor in the same application
program delete the row or updates an index column. This includes deletes and index column updates that are
performed as a result of rolling back to a savepoint.
This can also occur with a sensitive dynamic cursor when the FOR ROW n OF ROWSET clause is specified and the
specified row of the current rowset has been updated or deleted.

System action: The statement cannot be processed. No data was updated or deleted, and the cursor position is
unchanged.
Programmer response: Correct the logic of the application program to ensure that the cursor is correctly positioned
on the intended row of the object table before the UPDATE or DELETE statement is executed. Note that for single
row or non-rowset cursors, the cursors are not positioned on a row if FETCH returned SQLCODE +100.
SQLSTATE: 24504
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: Fri Nov 08, 2013 7:26 pm    Post subject:
Reply with quote

Hello,

Quote:
I have such requirement, that I should first fetch the next record and if some criteria meets, I shall issue COMMIT first before issue POSITIONED UPDATE. How should I do ?
This is Not the requirement. This is merely how you have chosen to implement.

If you explain the business requirement, someone might have an alternate suggestion.
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sat Nov 09, 2013 10:50 am    Post subject:
Reply with quote

hi, dick,
There is no specific requirement.
I tried this just want to have btter understaning of DB2.
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 10, 2013 5:49 am    Post subject:
Reply with quote

Hello,

As this should not be done, it will not lead to a better understanding of db2.

Other than this will cause problems.
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 -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am
No new posts JCL to fetch schedule status from act... parasmalik20 CA Products 1 Thu Jun 02, 2016 7:11 pm


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