oracle存储过程

有入参无返回的存储过程

create or replace procedure pro1
(title1 in t_forum.title%type,author1 in t_forum.author%type )
as
begin
  insert into t_forum(title,author)values(title1,author1);
exception
  when others then
    dbms_output.put_line('出错');
 end;
 
begin
  pro1('二手','哈哈作者');
  end;
===============================================在java中用call关键字调用存储过程

有入参有一个返回值的存储过程


create or replace procedure pro2
(id1 out t_user.id%type,name1 in t_user.name%type,pwd1 in t_user.pwd%type)
as
begin 
 insert into t_user(name,pwd)values(name1,pwd1);
exception
  when others then
    dbms_output.put_line('出错');
 end;

declare 
 id1 t_user.id%type;
begin
 pro2(id1,'aaa','123')
 dbms_output.put_line('成功'||id1)
end

包含动态语句的存储过程

procedure QueryMainDoctorWorkload(paraKSRQ00    in VARCHAR2, --开始日期
                                         paraJSRQ00    in VARCHAR2, -- 终止日期
                                         cur_ReportData out ref_cur)is
 VSQLSTR varchar2(2000);
 sCondetion varchar2(2000);

  begin
   if paraKSRQ00 is not null then
     sCondetion:=sCondetion||' and A.CJRQ00 between '''||paraKSRQ00||''' and '''||paraJSRQ00||''' ' ;
   end if;


VSQLSTR:='select (select   zwxm00 from bm_ygbm00 where ygbh00=ksys00) ZWXM00,';
     declare cursor cur_bmmc00 is
 select  REGEXP_SUBSTR(value0, '[^,]+', 1, l)bmmc00 from xt_xtcs00, (SELECT LEVEL l FROM dual CONNECT BY LEVEL <=20) b
    where name00='TJZXZJYSGZLTJBMMC'and  l <=  LENGTH(value0) -LENGTH(REPLACE(value0,',','')) + 1 ;--要统计的部门

    begin
     for vrow in cur_bmmc00 loop
            VSQLSTR:=VSQLSTR||' sum(case when BM =  '''||vrow.bmmc00||''' then 1 else 0 end) "'||vrow.bmmc00||'",' ;
     end loop;
    end;

VSQLSTR:=VSQLSTR||' sum(case when ksys00=shysid then 1 else 0 end)"报告解读" ,
            (select  count(1) from sy_pe_ywsj_tjz000 where zjysid =ksys00) "报告主检"
            from
            (
            select
             (select  bmmc00 from bm_bmbm00 where a.bmbh00=bmbh00) BM,
             a.*
            from sy_pe_ywsj_tjfkjc  a where 1=1  '||sCondetion||')

            group by ksys00';

    open cur_ReportData for VSQLSTR;


end;
 VSQLSTR := 'insert into SY_PE_YWSJ_TJKSWJ (LSID00, LB0000, TJH000, BMBH00, WJID00, WJXM00, CZY000)
            select SQ_PE_YWSJ_TJKSWJ_LSID00.nextval, 1, ' ||
                 paraTJH000 || ', ' || paraBMBH00 ||
                 ', WJID00, WJXM00, nvl(''' || paraCZY000 ||
                 ''', 0) from BM_BMWJ00 A where BMBH00 = ' || paraBMBH00 || '
            and YXBZ00 = ''1'' and not exists (select 1 from SY_PE_YWSJ_TJKSWJ where TJH000 = ' ||
                 paraTJH000 || ' and BMBH00 = ' || paraBMBH00 ||
                 ' and WJID00 = A.WJID00) ' || VSQL000;
      execute immediate VSQLSTR;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值