IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Cursor for update in fixed list select dynamic sql


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
manjuraveendran

New User


Joined: 09 Feb 2007
Posts: 2
Location: ernakulam

PostPosted: Mon Aug 13, 2007 4:02 pm
Reply with quote

Hi all,

Can we use cursor for update in fixed list select dynamic sql?
thanks
Manju
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Aug 13, 2007 9:17 pm
Reply with quote

Hello,

Please post example code of what you are askiing about.
Back to top
View user's profile Send private message
manjuraveendran

New User


Joined: 09 Feb 2007
Posts: 2
Location: ernakulam

PostPosted: Tue Aug 14, 2007 1:52 pm
Reply with quote

Hai my code is as follows,


In this code EMP is the table name,from which am trying to select the salary field for updation .

PROCEDURE DIVISION.
P1.
MOVE "SELECT SAL FROM EMP WHERE NAME = ? FOR UPDATE OF SAL"
TO X-TEXT.
MOVE 70 TO X-LEN.
EXEC SQL DECLARE CURSOR1 CURSOR FOR OB1
END-EXEC.
EXEC SQL PREPARE OB1 FROM :X END-EXEC.
MOVE "REN" TO NAME-TEXT.
MOVE 3 TO NAME-LEN.
EXEC SQL OPEN CURSOR1 USING :NAME END-EXEC.
PERFORM P2 UNTIL SQLCODE = 100.
EXEC SQL CLOSE CURSOR1 END-EXEC.
STOP RUN.
P2.
EXEC SQL FETCH CURSOR1 INTO :SAL END-EXEC.
IF SQLCODE = 0
COMPUTE SAL = SAL + 20
EXEC SQL UPDATE EMP SET SAL = :SAL WHERE CURRENT OF
CURSOR1 END-EXEC
DISPLAY "UPDATED"
ELSE
DISPLAY "NOT UPDATED".


Thanks
Manju
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 14, 2007 4:30 pm
Reply with quote

have you tried executing this?

if not and this is just a general question, I suggest that you go check out the manual.

this looks like a mish-mash of dynamic sql and imbedded sql. doubt if you could get it preprocessed or bound.

This is the v7 appl guide publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/FRAMESET/DSNAPH13/CCONTENTS?DT=20030508165437
and the v7 sql reference publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/CCONTENTS?DT=20010718164132

here is the v8 and v9 documentation: publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db2.doc.inst/bjnnmstr392.htm
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Pulling a fixed number of records fro... DB2 2
No new posts How to create a list of SAR jobs with... CA Products 3
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top