If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Sqlstate 24504

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-01-04, 05:48
ksolomon ksolomon is offline
Registered User
 
Join Date: Jun 2004
Posts: 38
Unhappy Sqlstate 24504

Hi Guys,
In a program I'm doing an operation as follows as my requirement is to update a column using cursor. But while using the FOR UPDATE OF clause in the cursor I'm getting the following error. Can you pls guide me in this regard?

db2 => DECLARE cur1 CURSOR WITH HOLD FOR select no from name FOR UPDATE OF no
DB20000I The SQL command completed successfully.

db2 => OPEN cur1
DB20000I The SQL command completed successfully.

db2 => FETCH cur1
NO
-----------
1
1 record(s) selected.

db2 => UPDATE name SET no=3 where CURRENT OF cur1
DB21031E The SQL statement using the cursor "CUR1" ("SQLCUR102") returned:
SQL0508N The cursor specified in the UPDATE or DELETE statement is not
positioned on a row. SQLSTATE=24504
db2 => ? 24504

SQLSTATE 24504: The cursor identified in the UPDATE, DELETE, SET, or GET
statement is not positioned on a row.
Reply With Quote
  #2 (permalink)  
Old 12-01-04, 09:52
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by ksolomon
Hi Guys,
In a program I'm doing an operation as follows as my requirement is to update a column using cursor. But while using the FOR UPDATE OF clause in the cursor I'm getting the following error. Can you pls guide me in this regard?

db2 => DECLARE cur1 CURSOR WITH HOLD FOR select no from name FOR UPDATE OF no
DB20000I The SQL command completed successfully.

db2 => OPEN cur1
DB20000I The SQL command completed successfully.

db2 => FETCH cur1
NO
-----------
1
1 record(s) selected.

db2 => UPDATE name SET no=3 where CURRENT OF cur1
DB21031E The SQL statement using the cursor "CUR1" ("SQLCUR102") returned:
SQL0508N The cursor specified in the UPDATE or DELETE statement is not
positioned on a row. SQLSTATE=24504
db2 => ? 24504

SQLSTATE 24504: The cursor identified in the UPDATE, DELETE, SET, or GET
statement is not positioned on a row.
Did you turn off autocommit? Start db2 with "db2 +c".
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On