Re: Using ORDER BY with UPDATE CURSORS (SE 5.1)
Posted in 1996
DECLARE c_select CURSOR FOR
SELECT PKColumn
FROM Table
WHERE <condition>
ORDER BY Column
DECLARE c_update CURSOR FOR
SELECT *
FROM Table
WHERE PKColumn = pk_variable
FOR UPDATE
FOREACH c_select INTO pk_variable
OPEN c_update
FETCH c_update INTO r_table.*
...[alter values]...
UPDATE Table SET * = r_table.* WHERE CURRENT OF c_update
CLOSE c_update
END FOREACH
The problem is not really version dependent -- ANSI SQL states that you
cannot declare a FOR UPDATE cursor on many query types, one major class of
which is those with an ORDER BY clause in them. HAVING, GROUP BY,
aggregates, INTO TEMP, etc are other things which lead to non-updatable
cursors.
Yours succinctly,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>Date: Mon, 8 Jan 96 14:29:55 GMT
>From: javeed anwar t <javi@psi.ernet.in>
>X-Informix-List-Id: <list.8376>
>
>I am facing a problem related to locking in INFORMIX SE 5.1.
>When I DECLARE a CURSOR FOR UPDATE using ORDER BY, at the time of
>opening, the Error is -365. This prevents me from using ORDER BY
>with UPDATE CURSOR. Pls explain some way to get out of this
>problem.