How to execute immediate a procedure from table in SP

hello, i have an issue. how to execute immediate a SP from data table.
example :

select source_code from tble_source;



create or replace procedure sp_2(param1, param2) return int as
v_result int:
v_exec varchar(200);
select source_code into v_exec from tble_source;

execute immediate v_exec into v_result using param1, param2;
return v_result;

***that code above doenst work, please kindly help. thanks in advance.

Welcome Missgeekcode! :wave:
Sorry you are experiencing this issue.
Are you on the managed or self-hosted service and what version?

We don’t support the “using” clause to substitute values into a string before executing it. So you need to put together a string with the whole command you want, plus parameters.

You could do a REPLACE to substitute parameters :1 and :2. Then EXECUTE IMMEDIATE the resulting string.

1 Like

hallo, thanks for the reply and i have another problem with execute immediate a SP inside a SP, that is not working with echo inside a SP. please kindly help. thanks.