动态调用存储过程(立即执行)Out参数问题 [英] Dynamic call Store Procedure (execute immediate ) Out parameters Problems
本文介绍了动态调用存储过程(立即执行)Out参数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在动态呼叫存储过程中遇到问题
I have problem Dynamic Call Store Procedure
v_sql := 'begin '|| p_procname || '(''test1'','' test2 '',:v_output2); end;';
execute immediate v_sql
using out v_output2 ;
dbms_output.put_line(v_output2 || ' ' );
在这里ı可以调用带有execute立即执行的过程.但是我的问题是动态绑定变量.此值来自日志表,然后我为execute_immediate过程进行解析
In here ı can call procedure with execute immediate . But my problem is dynamic bind variable . This values comes from log table then i parse for execute_immediate procedure
v_sql := 'begin '|| p_procname || '(''test1'','' test2'',:v_output2); end;';
v_sql1:= ||using|| 'out v_output2 ' ;
execute immediate v_sql
v_sql1;
它不能那样工作.我如何使动态变量绑定,因为我调用了很多过程,而该过程具有不同的输入和输出参数.希望您能理解我遇到的问题.如何解决这个问题
It doesnt work like that . How can i make dynamic variables bind , because i call a lot of procedure and thats procedure has different in and out parameters. I hope you can understand what problem i have .How can i pass this problems thx
推荐答案
这是简单的过程
create procedure test_proc(p_user varchar2, p_code varchar2, p_error varchar2) is
begin
p_error := p_user || p_code;
end;
相同的呼叫代码..
Declare
v_test_proc varchar2(50) := 'test_proc';
p_user varchar2(50) := 'test_name';
p_code varchar2(50) := 'test_code';
p_error varchar2(100);
v_sql varchar2(2000);
begin
v_sql := 'begin ' || v_test_proc || '( :1 ,:2, :3 ); end;';
execute immediate v_sql
using p_user, p_code, out p_error;
dbms_output.put_line(p_error);
end;
这篇关于动态调用存储过程(立即执行)Out参数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文