Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Query on Row Set Positioning Cursor Functionality

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
RedDevil711

New User


Joined: 04 Jun 2010
Posts: 25
Location: Pune

PostPosted: Thu May 10, 2012 1:34 pm    Post subject: Query on Row Set Positioning Cursor Functionality
Reply with quote

Hi,
I have been assigned a task to copy data from couple of existing columns to a couple of new columns added to the table. So i thought why not use the row set positioning cursor, it reduces calls and processing improves considerably.

The only problem was that the existing columns were declared as numeric(small int and integer to be precise) and both the new columns were declared as char.

the code i put in is some wat like this

EXEC SQL
DECLARE SEL_ALL CURSOR
WITH HOLD
WITH RETURN
WITH ROWSET POSITIONING FOR

SELECT NAME,
PLACE,
AGE,
DOB,
ID1,
ID2
FROM TABLE1
FOR UPDATE OF ID3,ID4
END-EXEC.
Here ID3 and ID4 are the new char columns, and ID1 and ID2 are supposed to be its inputs. I put in a piece of code to tally and convert numeric data to char , and am trying to update the values for ID3 and ID4 . Fetch query is as follows
EXEC SQL
FETCH NEXT ROWSET FROM SEL_ALL FOR 20 ROWS
..
END-EXEC.
Once inspect and tallying process is complete
the query i put in for update is
EXEC SQL
UPDATE TABLE1
SET ID3 = :WS-ID3,
ID4 = :WS-ID4
WHERE CURRENT OF SEL_ALL FOR ROW :WS-LOOP OF ROWSET
END-EXEC

Variable WS-LOOP is used in a perform syntax and it loops through the 20 rows fetched.

Now once i completed this and put my code to test, none of the rows get updated, if i remove the for ROW clause i get a -508, related to positioning of the row. Any inputs/help on this is welcome. icon_question.gif
Back to top
View user's profile Send private message

chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Thu May 10, 2012 3:30 pm    Post subject:
Reply with quote

Hi,

Are the values for WS-ID3 and WS-ID4 are coming properly when you tried to debug it?
Also when value fo WS-LOOP gets incremented?

Regards,
Chandan
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us