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 

Updating DB2 tables in succession

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


Joined: 16 May 2008
Posts: 8
Topics: 4

PostPosted: Thu Jul 30, 2009 11:16 pm    Post subject: Updating DB2 tables in succession Reply with quote

Hi,

There is a table T1. For each row of T1, I need to update tables T2, T3 and T4 in succession i.e if T2 update is successful, then update T3 and if T3 successful then T4 and so on. What is the shortest way to implement this logic in cobol db2 program.

thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 30, 2009 11:34 pm    Post subject: Reply with quote

deepthik,

1. Open cursor on table T1
2. Fetch cursor
3. Issue update on table t2
Code:

4. IF SQLCODE = 0 issue
      update on table t3
   else
     your error procedure
   end-if

5. IF SQLCODE = 0 issue
      update on table t4
   else
     your error procedure
   end-if

repeat step 2 thru 5 till end of cursor on table t1
Back to top
View user's profile Send private message Send e-mail Visit poster's website
deeptik
Beginner


Joined: 16 May 2008
Posts: 8
Topics: 4

PostPosted: Thu Jul 30, 2009 11:43 pm    Post subject: Reply with quote

Yes, this method can be used . I am trying to find if this entire process can be done by using cursors or is there any other way of doing this .
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Jul 31, 2009 11:39 am    Post subject: Reply with quote

deeptik,

You can also unload all the 4 tables in question and run the files thru utility/pgm and generate the updated record and load them back

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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