CREATE OR REPLACE FUNCTION delete_r_shukkin()
  RETURNS trigger AS $$
begin
insert into dat_rd_shukkin (
rirekino
,sakujofg
,shukkinno
,shukkinbi
,shiiresakicd
,projectcd
,biko
,shanaibiko
,tantoshaid
,bushocd
,shoninnichiji
,shoninshaid
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
  ) values (
nextval('sqns_shukkinrirekino')
,true
,old.shukkinno
,old.shukkinbi
,old.shiiresakicd
,old.projectcd
,old.biko
,old.shanaibiko
,old.tantoshaid
,old.bushocd
,old.shoninnichiji
,old.shoninshaid
,old.sakuseiuserid
,old.sakuseinichiji
,old.koshinuserid
,old.koshinnichiji
  );
insert into dat_rm_shukkin (
rirekino
,shukkinno
,gyono
,oyameisaicd
,meisaicd
,meisaikb
,kessaikb
,shukkinkb
,shukkinkingaku
,kazeikb
,shohizeiritsu
,shohizeigaku
,kozacd
,tegatabango
,tegatafuridashibasho
,tegatafuridashibi
,tegatamankibi
,biko
,shanaibiko
,shukkinkarikatakamokucd
,shukkinkashikatakamokucd
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
) select
currval('sqns_shukkinrirekino')
,ms.shukkinno
,ms.gyono
,ms.oyameisaicd
,ms.meisaicd
,ms.meisaikb
,ms.kessaikb
,ms.shukkinkb
,ms.shukkinkingaku
,ms.kazeikb
,ms.shohizeiritsu
,ms.shohizeigaku
,ms.kozacd
,ms.tegatabango
,ms.tegatafuridashibasho
,ms.tegatafuridashibi
,ms.tegatamankibi
,ms.biko
,ms.shanaibiko
,ms.shukkinkarikatakamokucd
,ms.shukkinkashikatakamokucd
,ms.sakuseiuserid
,ms.sakuseinichiji
,ms.koshinuserid
,ms.koshinnichiji
from dat_m_shukkin ms
where ms.shukkinno = old.shukkinno
;
return new;
end;
$$
LANGUAGE plpgsql;
