Results 1 to 2 of 2

Thread: Sqlstate 24504

  1. #1
    Join Date
    Jun 2004
    Posts
    38

    Unhappy Unanswered: 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.

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •