CREATE OR REPLACE FUNCTION insert_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')
,false
,new.mitsumorino
,new.mitsumoribi
,new.tokuisakicd
,new.tokuisakiatena
,new.projectcd
,new.biko
,new.shanaibiko
,new.tantoshaid
,new.bushocd
,new.tankarankcd
,new.shoninnichiji
,new.shoninshaid
,new.mitsumorikenmei
,new.yukokigen
,new.nohinbi
,new.nohinbasho
,new.shiharaijoken
,new.sakuseiuserid
,new.sakuseinichiji
,new.koshinuserid
,new.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 = new.mitsumorino
;
return new;
end;
$$
LANGUAGE plpgsql;
