Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    107

    Unanswered: CURSOR with ORDER BY query

    friends,

    i want to declare a cursor for a select statement with ORDER BY clause, but DB2
    considers the result table as read-only and does n't allow me to update... i want to manipulate the result table and update the table.... can anyone know how to achieve this ????

    DB2 UDB v8.1.3 /windows 2000

    Jake

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Please post the statement.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Feb 2004
    Posts
    107
    sorry for late reply....

    Marcus, here is the example code... can you tell me how can i achieve this a cursor with order by in the select statement....
    -----------------------------------------------------------------------------------
    CREATE TABLE CFUT (TEST INT, TEST1 VARCHAR(20))
    @
    CREATE PROCEDURE CURSORWITHORDERBY
    LANGUAGE SQL
    BEGIN
    DECLARE cur1 CURSOR FOR SELECT TEST1 FROM CFUT ORDER BY TEST FOR UPDATE OF TEST;
    INSERT INTO CFUT VALUES(1, 'JAI');
    INSERT INTO CFUT VALUES(2, 'JAI1');
    INSERT INTO CFUT VALUES(3, 'JAI2');

    OPEN cur1;
    UPDATE CFUT SET TEST=4, TEST1='KARTHI' WHERE CURRENT OF cur1;
    CLOSE cur1;
    END
    @
    -----------------------------------------------------------------------------------

    Jake

Posting Permissions

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