oracle调用带in out参数的存储过程

来源:互联网 发布:mac草图大师如何破解 编辑:程序博客网 时间:2024/03/29 23:32
定义了一个存储过程;
create or replace procedure FindBaseInfo(
  v_id in out number,
  v_name out varchar2,
  v_title out varchar2
)

is
temp integer(2);
begin   
    
  select count(*) into temp from employee where id=v_id;
  if temp>0 then
  select id,name,title into v_id,v_name,v_title from employee where id=v_id;
  dbms_output.put_line('succeed!');  
  else  
  v_id:=0;
  dbms_output.put_line('failed!');
  end if;

end;


调用过程如下:

DECLARE
 a   number ;
 b   varchar2(10);
 c   varchar2(10);
 begin
 a:=&a;
 FindBaseInfo(a,b,c);
end;


这里不能直接这样调用: FindBaseInfo(1,b,c);因为存储过程的第一个参数设为in out类型的。所以需要传一个变量当做参数,否则整形的话没法赋值输出。!!IN OUT具有前两种模式的特性,即调用时,实参的值总是传递给形参,结束时,形参的值传递给实参。调用时,对于IN模式的实参可以是常量或变量,但对于OUT和IN OUT模式的实参必须是变量。



原创粉丝点击