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 > Running a procedure from a procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-08-03, 14:31
soumil soumil is offline
Registered User
 
Join Date: Jul 2003
Posts: 30
Running a procedure from a procedure

Hi,
Lets say I have procedures called AAA_INS_UPS_DEL, BBB_INS_DEL_UPD...etc
AAA, BBB etc are the table names.
How can I run these procedures dynamically from the procedure A123.
The procedure listed below will help you understand what I am trying to do.

Thanks for the help.
-Soumil

****************************
Create procedure a123
declare v_procname varchar(100);
Declare v_tablename varchar(100);
Declare SQLSTATE VARChar(5);
Declare v_param1 varchar(15);
Declare v_param2 varchar(15);
Declare cur_tblname cursor for
select name from ListOfTables;

open cur_tblname;

Fetch cur_tblname into v_tablename;
While (SQLSTATE = '00000') do

SEt v_param1 = 'InputParameter1';
set v_param2 = 'InputParameter2';
set v_procname = v_table_name || '_ins_upd_del ' || v_param1 || ' , ' || v_param2 ;

-- How do I run the procedures named after the TABLENAMES
-- For Eg Lets say we have three tables AAA, BBB CCC
-- The Cursor would pick up one table at a time and
-- the string v_procname will be 'AAA_ins_upd_del'

call v_procname ;


End While;
Close cur_tblname;

end
Reply With Quote
  #2 (permalink)  
Old 08-08-03, 15:49
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Running a procedure from a procedure

See if this thread helps

http://dbforums.com/showthread.php?threadid=873480

Sathyaram



Quote:
Originally posted by soumil
Hi,
Lets say I have procedures called AAA_INS_UPS_DEL, BBB_INS_DEL_UPD...etc
AAA, BBB etc are the table names.
How can I run these procedures dynamically from the procedure A123.
The procedure listed below will help you understand what I am trying to do.

Thanks for the help.
-Soumil

****************************
Create procedure a123
declare v_procname varchar(100);
Declare v_tablename varchar(100);
Declare SQLSTATE VARChar(5);
Declare v_param1 varchar(15);
Declare v_param2 varchar(15);
Declare cur_tblname cursor for
select name from ListOfTables;

open cur_tblname;

Fetch cur_tblname into v_tablename;
While (SQLSTATE = '00000') do

SEt v_param1 = 'InputParameter1';
set v_param2 = 'InputParameter2';
set v_procname = v_table_name || '_ins_upd_del ' || v_param1 || ' , ' || v_param2 ;

-- How do I run the procedures named after the TABLENAMES
-- For Eg Lets say we have three tables AAA, BBB CCC
-- The Cursor would pick up one table at a time and
-- the string v_procname will be 'AAA_ins_upd_del'

call v_procname ;


End While;
Close cur_tblname;

end
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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