Oracle存储函数写法及调用

1.右键导航创建函数界面

 

 

2.返回值FunctionResult可自定义,当函数有输出函数时可不传数据,但需要设置返回(当提示未限定返回长度时,如代码示例设置255长度皆可);

-------使用函数右键引导创建范例
create or replace function get_rvv_rvb_img38(p_img05 in varchar2, p_img06 in number,p_img38 out varchar2) return varchar2 is
  FunctionResult varchar2(255);
begin
  if p_img38 is  null and p_img05 is not null and p_img06 is not null         then
   
  select  beizhu into p_img38
            from (select rownum xuhao,rvv01,rvv02, 
                 rvvud01 beizhu,rvu03                
             from rvv_file
             join rvu_file  on rvu01 = rvv01
            where  rvuconf='Y' and rvv04=p_img05 and rvv05=p_img06
          )
   where xuhao = '1';
     end if ;
  return(FunctionResult);
end get_rvv_rvb_img38;

3.调用函数

begin
  -- Call the function
  :result := get_rvv_rvb_img38(p_img05 => :p_img05,
                               p_img06 => :p_img06,
                               p_img38 => :p_img38);
end;

4.测试返回结果:

 

posted @ 2022-12-19 16:30  三生有幸格格  阅读(287)  评论(1编辑  收藏  举报