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
 

 

Cursor for update in fixed list select dynamic sql

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Cursor for update in fixed list select dynamic sql
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

Site Director


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

PostPosted: Mon Aug 13, 2007 9:17 pm    Post subject:
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    Post subject:
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    Post subject:
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 http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/FRAMESET/DSNAPH13/CCONTENTS?DT=20030508165437
and the v7 sql reference http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/CCONTENTS?DT=20010718164132

here is the v8 and v9 documentation: http://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    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 Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm


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