Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

oracle - Dynamic call Store Procedure (execute immediate ) Out parameters Problems

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 || ' ' );

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

here is simple procedure

 create procedure test_proc(p_user varchar2, p_code varchar2, p_error varchar2) is
 begin
   p_error := p_user || p_code;
 end; 

calling code for same ..

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...