MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cursor and Update at the same time

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
lacoe1
Beginner


Joined: 24 Feb 2005
Posts: 33
Topics: 17

PostPosted: Wed Mar 24, 2010 5:59 pm    Post subject: Cursor and Update at the same time Reply with quote

I am using a cursor in my Cobol program and it's gathering all the right records. What I would like to do is update some of the records that I have fetched from that cursor. How can I do update at the same time as processing the cursor?
Back to top
View user's profile Send private message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Wed Mar 24, 2010 6:27 pm    Post subject: Reply with quote

Here's an example:
Code:

EXEC SQL                                         
     DECLARE CURPRBL CURSOR WITH HOLD FOR       
       SELECT  SSNO                             
              ,MEDDEN_BAL                       
              ,LAST_MEDDEN_UP                   
              ,USERID                           
              ,LASTUPDT                         
          FROM HOURS.PREMBAL                     
              WHERE MEDDEN_BAL < 0               
     FOR UPDATE OF MEDDEN_BAL, LAST_MEDDEN_UP,   
                   USERID, LASTUPDT             
END-EXEC.                                       

EXEC SQL                                               
     UPDATE HOURS.PREMBAL                               
          SET MEDDEN_BAL     = :PREMBAL-MEDDEN-BAL     
             ,LAST_MEDDEN_UP = :PREMBAL-LAST-MEDDEN-UP 
             ,USERID         = :PREMBAL-USERID         
             ,LASTUPDT       = :PREMBAL-LASTUPDT       
        WHERE CURRENT OF CURPRBL                       
END-EXEC.

_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Wed Mar 24, 2010 6:31 pm    Post subject: Reply with quote

lacoe1,

Read about Using positioned UPDATE statements here

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/dsnapj12/2.2.1.4.2

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
lacoe1
Beginner


Joined: 24 Feb 2005
Posts: 33
Topics: 17

PostPosted: Thu Mar 25, 2010 12:31 pm    Post subject: Reply with quote

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group