CREATE OR REPLACE FUNCTION delete_r_nyukin()
  RETURNS trigger AS $$
begin
insert into dat_rd_nyukin (
rirekino
,sakujofg
,nyukinno
,nyukinbi
,tokuisakicd
,projectcd
,biko
,shanaibiko
,tantoshaid
,bushocd
,shoninnichiji
,shoninshaid
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
  ) values (
nextval('sqns_nyukinrirekino')
,true
,old.nyukinno
,old.nyukinbi
,old.tokuisakicd
,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_nyukin (
rirekino
,nyukinno
,gyono
,oyameisaicd
,meisaicd
,meisaikb
,kessaikb
,nyukinkb
,nyukinkingaku
,kazeikb
,shohizeiritsu
,shohizeigaku
,kozacd
,tegatabango
,tegatafuridashibasho
,tegatafuridashibi
,tegatamankibi
,biko
,shanaibiko
,nyukinkarikatakamokucd
,nyukinkashikatakamokucd
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
) select
currval('sqns_nyukinrirekino')
,mn.nyukinno
,mn.gyono
,mn.oyameisaicd
,mn.meisaicd
,mn.meisaikb
,mn.kessaikb
,mn.nyukinkb
,mn.nyukinkingaku
,mn.kazeikb
,mn.shohizeiritsu
,mn.shohizeigaku
,mn.kozacd
,mn.tegatabango
,mn.tegatafuridashibasho
,mn.tegatafuridashibi
,mn.tegatamankibi
,mn.biko
,mn.shanaibiko
,mn.nyukinkarikatakamokucd
,mn.nyukinkashikatakamokucd
,mn.sakuseiuserid
,mn.sakuseinichiji
,mn.koshinuserid
,mn.koshinnichiji
from dat_m_nyukin mn
where mn.nyukinno = old.nyukinno
;
return new;
end;
$$
LANGUAGE plpgsql;
