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 > CURSOR with ORDER BY query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-04, 06:36
Jake K Jake K is offline
Registered User
 
Join Date: Feb 2004
Posts: 107
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
Reply With Quote
  #2 (permalink)  
Old 08-16-04, 09:36
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
  #3 (permalink)  
Old 08-18-04, 09:37
Jake K Jake K is offline
Registered User
 
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
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