All Forums Database
thomas.wolf 2 posts Joined 08/14
28 Aug 2014
Calling Stored Procedures from Dynamic SQL Statement

is there a way to call a stored procedure from a dynamic SQL statement? I don't know the name of the stored procedure at compile time, so I have to build the SQL command invoking the SP dynamically.
Thank you in advance,

Raja_KT 1246 posts Joined 07/09
28 Aug 2014
I dont think that can be done,also in other databases that I know too. sTored procs are called or
 compiled , example below

CALL abc (1, amt);
.compile file def.spl

Maybe you can break up into conditional logics.
Let us hear from others too, if I miss out on this functionality.

Raja K Thaw
My wiki:
Street Children suffer not by their fault. We can help them if we want.

dnoeth 4628 posts Joined 11/04
28 Aug 2014

Hi Thomas,
check the SQL Stored Procedures and Embedded SQL manual.
There's a section named SQL Statements that Cannot Be Used Dynamically and CALL is one of them.


thomas.wolf 2 posts Joined 08/14
29 Aug 2014

Hi Raja, hi Dieter,
thank you very much for your answers. I pretty much expected your answers, but I just wanted to be sure if there's another way of invoking SPs that I was not aware of.
Fortunatelly, I don't really need to invoke SPs dynamically - basically there's a finite set of SPs that will possibly be called.  I don't know this set by now, but at some point in the future. So I am going to do what Raja suggested - break it up into conditional logic and invoke the SPs in a static way. That should do the trick.
Thanks for your help,

You must sign in to leave a comment.