CREATE OR REPLACE FUNCTION delete_r_ukeharai()
  RETURNS trigger AS $$
begin
insert into dat_rd_ukeharai (
rirekino
,sakujofg
,ukeharaino
,uriageno
,shiireno
,ukeharaibi
,projectcd
,biko
,shanaibiko
,tantoshaid
,bushocd
,shoninnichiji
,shoninshaid
,hinmokuhenkan
,denpyosakuseikb
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
  ) values (
nextval('sqns_ukeharairirekino')
,true
,old.ukeharaino
,old.uriageno
,old.shiireno
,old.ukeharaibi
,old.projectcd
,old.biko
,old.shanaibiko
,old.tantoshaid
,old.bushocd
,old.shoninnichiji
,old.shoninshaid
.old.hinmokuhenkan
,old.denpyosakuseikb
,old.sakuseiuserid
,old.sakuseinichiji
,old.koshinuserid
,old.koshinnichiji
  );
insert into dat_rm_ukeharai (
rirekino
,ukeharaino
,gyono
,oyameisaicd
,meisaicd
,meisaikb
,hinmokucd
,hinmokumei
,kikaku
,kataban
,lotno
,seizobi
,shohikigen
,suryo
,tanicd
,zaikotanka
,zaikokingaku
,biko
,shanaibiko
,shukkosokocd
,shukkolocationcd
,nyukosokocd
,nyukolocationcd
,ukeharaikarikatakamokucd
,ukeharaikashikatakamokucd
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
) select
currval('sqns_ukeharairirekino')
,mu.ukeharaino
,mu.gyono
,mu.oyameisaicd
,mu.meisaicd
,mu.meisaikb
,mu.hinmokucd
,mu.hinmokumei
,mu.kikaku
,mu.kataban
,mu.lotno
,mu.seizobi
,mu.shohikigen
,mu.suryo
,mu.tanicd
,mu.zaikotanka
,mu.zaikokingaku
,mu.biko
,mu.shanaibiko
,mu.shukkosokocd
,mu.shukkolocationcd
,mu.nyukosokocd
,mu.nyukolocationcd
,mu.ukeharaikarikatakamokucd
,mu.ukeharaikashikatakamokucd
,mu.sakuseiuserid
,mu.sakuseinichiji
,mu.koshinuserid
,mu.koshinnichiji
from dat_m_ukeharai mu
where mu.ukeharaino = old.ukeharaino
;
return new;
end;
$$
LANGUAGE plpgsql;
