create or replace trigger auto_add_recordfor_da_ws_yjqd
after insert on da_oa_fwgz
for each row
declare
t_rq date;
t_yjdw number(5);
t_bh number(8);
-- local variables here
begin
t_rq:=to_date(to_number(:new.nian),to_number(:new.yue),to_number(new.ri))
select csbm into t_yjdw from da_csbm
where csmc=:new.fawenchushi;
if t_yjdw>0 then
select max(bh)
into t_bh
from da_ws_yjqd
where nd=to_number(:new.nian) and yjdw=t_yjdw and qxbm='qj';
t_bh:=t_bh+1
insert into da_ws_yjqd (nd,yjdw,bh,wh,zrz,wjtm,rq,fj,qxbm,xhbz)
values (to_number(new.nian),t_yjdw,t_bh,new.fwzh,new.zrz,new.ztc,t_rq,new.path,'qj',0);
end if;
end auto_add_recordfor_da_ws_yjqd;
after insert on da_oa_fwgz
for each row
declare
t_rq date;
t_yjdw number(5);
t_bh number(8);
-- local variables here
begin
t_rq:=to_date(to_number(:new.nian),to_number(:new.yue),to_number(new.ri))
select csbm into t_yjdw from da_csbm
where csmc=:new.fawenchushi;
if t_yjdw>0 then
select max(bh)
into t_bh
from da_ws_yjqd
where nd=to_number(:new.nian) and yjdw=t_yjdw and qxbm='qj';
t_bh:=t_bh+1
insert into da_ws_yjqd (nd,yjdw,bh,wh,zrz,wjtm,rq,fj,qxbm,xhbz)
values (to_number(new.nian),t_yjdw,t_bh,new.fwzh,new.zrz,new.ztc,t_rq,new.path,'qj',0);
end if;
end auto_add_recordfor_da_ws_yjqd;
insert into da_ws_yjqd (nd,yjdw,bh,wh,zrz,wjtm,rq,fj,qxbm,xhbz)
values (to_number(:new.nian),t_yjdw,t_bh,:new.fwzh,:new.zrz,:new.ztc,t_rq,:new.path,'qj',0);