Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Dynamially call a Stored Procedure within a stored Procedure

$
0
0

Hello,

 

I want to call a Stored Procedure from another Stored Procedure, dynamically. I have pasted a code snippet below:

 

Eg: I have few Stored Procs as below:

 

CREATE PROCEDURE CAL_DISCOUNT(IN value1 INTEGER, IN disc INTEGER) AS

BEGIN

...

..
.

END;


CREATE PROCEDURE CAL_DISCOUNT_V1(IN value1 INTEGER, IN disc INTEGER) AS

BEGIN

...

..
.

END;


Now I have my main Stored Proc which takes the name of the procedure to call as an input:


CREATE PROCEDURE MY_PROC( IN dyn_proc_name nvarchar(50) AS

BEGIN

...

CALL dyn_proc_name (:var1, :var2);

..

...

 

END;


I want to now call the main proc as below:


CALL MY_PROC('CAL_DISCOUNT');


This should call CAL_DISCOUNT and pass 2 values (defined within the PROCEDURE MY_PROC) dynamically. I was able to call a Procedure using EXECUTE IMMEDIATE when the procedure did not take any input. But when I call a procedure and pass an input it fails. I tried 'USING' syntax with EXECUTE IMMEDITATE, but it was throwing error.

Any pointers?


Regards,



Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>