一個存儲過程的例子

create or replace procedure p_pre_saveimp(v_oprcd in varchar2,returnFlag out varchar2) is
v_jrfflag varchar2(2);--記錄標識
v_jrfno varchar2(12);--享受編號
v_gntoprcd varchar2(10);
v_gntdept varchar2(4);
v_gntoprdt varchar2(10);
begin
  declare cursor cur_jlsrelief_tmp is
  select jrfno,jrfflag,gntoprcd,gntdept,to_char(gntoprdt,'yyyy-mm-dd') gntoprdt  from jlsrelief_temp;
  begin
  open cur_jlsrelief_tmp;
  loop
  fetch cur_jlsrelief_tmp into v_jrfno,v_jrfflag,v_gntoprcd,v_gntdept,v_gntoprdt;
  exit when cur_jlsrelief_tmp%notfound;
  begin
    if v_jrfflag = '4' then
    begin
      update jlsrelief_t set jrfstatus ='2' where jrfno = v_jrfno;
      update jlsgrant_t set gntnote =v_oprcd||':'||sysdate||'發放取消' where gntno = v_jrfno;
    end;
    end if;
    if v_jrfflag = '1' then
    begin
      update jlsrelief_t set jrfstatus = '3' where jrfno = v_jrfno;
      update jlsgrant_t set gntcheckin ='1',gntdept = v_gntdept,gntoprcd = v_oprcd,gntleavmn =0,gntnote =v_gntoprcd||':'||v_gntoprdt where gntno = v_jrfno;
    end;
    end if;
    if v_jrfflag = '2' then
    begin
      update jlsrelief_t set jrfstatus = '2' where jrfno = v_jrfno;
      update jlsgrant_t set gntnote ='重新導出'||v_oprcd||':'||sysdate where gntno = v_jrfno;
    end;
    end if;
    returnFlag := '1';
  end;
  end loop;
  commit;
  close cur_jlsrelief_tmp;
  end;
end p_pre_saveimp;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章