| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| deeptik Beginner
 
 
 Joined: 16 May 2008
 Posts: 8
 Topics: 4
 
 
 | 
			
				|  Posted: Thu Jul 30, 2009 11:16 pm    Post subject: Updating DB2 tables in succession |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Thu Jul 30, 2009 11:34 pm    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| deeptik Beginner
 
 
 Joined: 16 May 2008
 Posts: 8
 Topics: 4
 
 
 | 
			
				|  Posted: Thu Jul 30, 2009 11:43 pm    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Fri Jul 31, 2009 11:39 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		|  | 
	
		|  |