CREATE OR REPLACE FUNCTION insert_r_juchu()
  RETURNS trigger AS $$
begin
insert into dat_rd_juchu (
rirekino
,sakujofg
,juchuno
,juchubi
,tokuisakicd
,tokuisakiatena
,projectcd
,biko
,shanaibiko
,tantoshaid
,bushocd
,tankarankcd
,shoninnichiji
,shoninshaid
,maeukenyukinbi
,maeukekingaku
,kessaikb
,denpyosakuseikb
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
  ) values (
nextval('sqns_juchurirekino')
,false
,new.juchuno
,new.juchubi
,new.tokuisakicd
,new.tokuisakiatena
,new.projectcd
,new.biko
,new.shanaibiko
,new.tantoshaid
,new.bushocd
,new.tankarankcd
,new.shoninnichiji
,new.shoninshaid
,new.maeukenyukinbi
,new.maeukekingaku
,new.kessaikb
,new.denpyosakuseikb
,new.sakuseiuserid
,new.sakuseinichiji
,new.koshinuserid
,new.koshinnichiji
  );
insert into dat_rm_juchu (
rirekino
,juchuno
,gyono
,oyameisaicd
,meisaicd
,meisaikb
,hinmokucd
,hinmokumei
,kikaku
,kataban
,lotno
,nisugatacd
,suryo
,tanicd
,teika
,tanka
,kazeikb
,shohizeiritsu
,kingaku
,noki
,biko
,shanaibiko
,shukkosokocd
,nyukosokocd
,haisosakino
,haisomemo
,juchujotai
,hatchujotai
,shukkajotai
,yoteihaisobi
,yoteinyukabi
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
) select
currval('sqns_juchurirekino')
,mj.juchuno
,mj.gyono
,mj.oyameisaicd
,mj.meisaicd
,mj.meisaikb
,mj.hinmokucd
,mj.hinmokumei
,mj.kikaku
,mj.kataban
,mj.lotno
,mj.nisugatacd
,mj.suryo
,mj.tanicd
,mj.teika
,mj.tanka
,mj.kazeikb
,mj.shohizeiritsu
,mj.kingaku
,mj.noki
,mj.biko
,mj.shanaibiko
,mj.shukkosokocd
,mj.nyukosokocd
,mj.haisosakino
,mj.haisomemo
,mj.juchujotai
,mj.hatchujotai
,mj.shukkajotai
,mj.yoteihaisobi
,mj.yoteinyukabi
,mj.sakuseiuserid
,mj.sakuseinichiji
,mj.koshinuserid
,mj.koshinnichiji
from dat_m_juchu mj
where mj.juchuno = new.juchuno
;
return new;
end;
$$
LANGUAGE plpgsql;
