oracle 函数调用

时间:2021-09-02 17:19:46

--带out的函数

create or replace function fun_try(v_name varchar,v_outname out varchar)
return varchar2 is Result varchar2(200);
begin
  select smenuname,smenuname into Result,v_outname from sm_menus where smenucode = 'GL01';
  v_outname :=Result;
   return(Result);
end fun_try;

--命令窗口
begin
var v_outname varchar2(20)
var dname varchar2(20)
exec :dname:=fun_try('SCOTT',:v_outname)
  print(:v_outname)
 end;

--sql窗口执行

declare
  v_outname varchar2(20);
  dname     varchar2(20);
begin
  dname := fun_try('SCOTT', v_outname);
  dbms_output.put_line(v_outname);
end;

--函数

create or replace function fun_try(v_name varchar)
return varchar2 is Result varchar2(200);
begin
  select smenuname into Result from sm_menus where smenucode = 'GL01';
  --v_outname :=Result;
  return(Result);
end fun_try;

select fun_try('1') from dual