If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Possible to set up stored procedures that call each other?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-23-10, 15:25
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Possible to set up stored procedures that call each other?

Hi,

Is it possible to create stored procedures in this manner --

CREATE PROCEDURE TEST1 ()
-------------------
------------------
BEGIN
if some condition is met THEN
CALL TEST2 ();
END IF;
--------------------
--------------------
END
@


CREATE PROCEDURE TEST2 ()
.................................................. ...............
.................................................. ...............
BEGIN
.................................................. ...............
WHILE condition = 1 DO
CALL TEST1 ();
END WHILE;
END
@


The entry point will always be TEST1 ()....if I try to create them using the regular db2 -td@ -vf <filename>, then it complains that the other procedure doesn't exist... is there a way to accomplish this? thanks!!
Reply With Quote
  #2 (permalink)  
Old 04-23-10, 15:32
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You can try:

1) create TEST1 without the call to TEST2
2) create TEST2
3) recreate TEST1 with the call to TEST2
4) REBIND TEST2

Andy
Reply With Quote
  #3 (permalink)  
Old 04-23-10, 15:39
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
great, thanks! will try it out...will the rebind command just be like this --

db2 "rebind procedure test2" or something else?

thanks so much for the quick reply!
Reply With Quote
  #4 (permalink)  
Old 04-23-10, 15:47
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
No. You rebind packages. Look at the rebind command in the reference. If you are on V9.5 or later you can use this SP to do it easier: IBM DB2 9.5 Information Center for Linux, UNIX, and Windows

Andy
Reply With Quote
  #5 (permalink)  
Old 04-23-10, 16:31
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
thanks, will look into it.. we are using V8.2..
Reply With Quote
  #6 (permalink)  
Old 04-27-10, 18:31
db2user24 db2user24 is offline
Registered User
 
Join Date: Nov 2007
Posts: 248
Quote:
Originally Posted by ARWinner View Post
You can try:

1) create TEST1 without the call to TEST2
2) create TEST2
3) recreate TEST1 with the call to TEST2
4) REBIND TEST2

Andy

Hey Andy, thought you might be interested in knowing that I did steps 1 - 3 and the proc worked right after that. It didn't seem to need step 4 which I thought was a little odd since I dropped TEST1 and created it again (step 3).. it's interesting that it didn't mark it inoperative and didn't ask for any rebinding?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On