如题:
一个带out参数的存储过程如下:
create or replace procedure ddd(
          tid in varchar2,
          msg in varchar2,
          tel in varchar2,
          out_code out number, 
          ou_message out varchar2
          ) is     
begin
--sql 
 /*
 * .......在此略过很多 sql
 */
  update t_customer_tel set status='1',message=msg,telphone=tel where tid= tid;
  commit;
  exception 
    when others then
        rollback;
        out_code:=-1;
        ou_message=sqlerrm;
    return;    
end ttt;
--在下面的存储过程里面需要调用ddd这个存储过程,但是因为有out参数,所以一直没有搞定?,如何弄......
create or replace procedure ttt is
       TYPE t_type IS TABLE OF t_repository.pk_auto_id%TYPE;
       v_id         t_type;
       v_sql varchar2(200);
begin
  v_sql:='select pk_auto_id from t_repository';
    execute immediate v_sql BULK COLLECT
               INTO v_id;
  for i in 1 .. v_id.count loop   
     exec ddd('9876923','update the msg !','098712341234');--???这里报错,如何调用呢,网上说@v1 output,也不好用啊!
   end loop;
end ttt;

解决方案 »

  1.   

    create or replace procedure ttt is 
          TYPE t_type IS TABLE OF t_repository.pk_auto_id%TYPE; 
          v_id        t_type; 
          v_sql varchar2(200); 
          -- add 2 var
          v_out_code     number;
          v_out_message varchar2;
    begin 
      v_sql:='select pk_auto_id from t_repository'; 
        execute immediate v_sql BULK COLLECT 
                  INTO v_id; 
      for i in 1 .. v_id.count loop  
        --exec ddd('9876923','update the msg !','098712341234'); 
        ddd('9876923','update the msg !','098712341234',v_out_code,v_out_message); 
      end loop; 
    end ttt; 
      

  2.   

    直接调用,不用加 exec这个词的,exec是在sqlplus下单独调用的时候用的
      

  3.   

    你执行ddd的目的是要得到Out传出的结果,但是ttt里面并没有设置接收结果的变量,当然会出问题啦程序块里面调用procedure不需要exec
      

  4.   

    写错,
    “执行ddd的目的是要得到Out传出的结果”“执行ddd需要得到Out传出的结果”
    default类型非必须的out参数除外