CREATE OR REPLACE FUNCTION delete_r_mitsumori()
  RETURNS trigger AS $$
begin
insert into dat_rd_mitsumori (
rirekino
,sakujofg
,mitsumorino
,mitsumoribi
,tokuisakicd
,tokuisakiatena
,projectcd
,biko
,shanaibiko
,tantoshaid
,bushocd
,tankarankcd
,shoninnichiji
,shoninshaid
,mitsumorikenmei
,yukokigen
,nohinbi
,nohinbasho
,shiharaijoken
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
  ) values (
nextval('sqns_mitsumoririrekino')
,true
,old.mitsumorino
,old.mitsumoribi
,old.tokuisakicd
,old.tokuisakiatena
,old.projectcd
,old.biko
,old.shanaibiko
,old.tantoshaid
,old.bushocd
,old.tankarankcd
,old.shoninnichiji
,old.shoninshaid
,old.mitsumorikenmei
,old.yukokigen
,old.nohinbi
,old.nohinbasho
,old.shiharaijoken
,old.sakuseiuserid
,old.sakuseinichiji
,old.koshinuserid
,old.koshinnichiji
  );
insert into dat_rm_mitsumori (
rirekino
,mitsumorino
,gyono
,oyameisaicd
,meisaicd
,meisaikb
,hinmokucd
,hinmokumei
,kikaku
,kataban
,nisugatacd
,suryo
,tanicd
,teika
,tanka
,kazeikb
,shohizeiritsu
,shohizeigaku
,choseishohizeigaku
,kingaku
,noki
,biko
,shanaibiko
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
) select
currval('sqns_mitsumoririrekino')
,mu.mitsumorino
,mu.gyono
,mu.oyameisaicd
,mu.meisaicd
,mu.meisaikb
,mu.hinmokucd
,mu.hinmokumei
,mu.kikaku
,mu.kataban
,mu.nisugatacd
,mu.suryo
,mu.tanicd
,mu.teika
,mu.tanka
,mu.kazeikb
,mu.shohizeiritsu
,mu.shohizeigaku
,mu.choseishohizeigaku
,mu.kingaku
,mu.noki
,mu.biko
,mu.shanaibiko
,mu.sakuseiuserid
,mu.sakuseinichiji
,mu.koshinuserid
,mu.koshinnichiji
from dat_m_mitsumori mu
where mu.mitsumorino = old.mitsumorino
;
return new;
end;
$$
LANGUAGE plpgsql;
