CREATE OR REPLACE FUNCTION delete_r_shiire()
 RETURNS trigger
AS $$
begin
insert into dat_rd_shiire (
rirekino
,sakujofg
,shiireno
,shiirebi
,shiiresakicd
,hatchushono
,projectcd
,biko
,shanaibiko
,tantoshaid
,bushocd
,shoninnichiji
,shoninshaid
,shiharaishimebi
,shiharaiyoteibi
,kessaikb
,denpyosakuseikb
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
  ) values (
nextval('sqns_shiirerirekino')
,true
,old.shiireno
,old.shiirebi
,old.shiiresakicd
,old.hatchushono
,old.projectcd
,old.biko
,old.shanaibiko
,old.tantoshaid
,old.bushocd
,old.shoninnichiji
,old.shoninshaid
,old.shiharaishimebi
,old.shiharaiyoteibi
,old.kessaikb
,old.denpyosakuseikb
,old.sakuseiuserid
,old.sakuseinichiji
,old.koshinuserid
,old.koshinnichiji
  );
insert into dat_rm_shiire (
rirekino
,shiireno
,gyono
,hatchushogyono
,oyameisaicd
,meisaicd
,meisaikb
,hinmokucd
,hinmokumei
,aitesakihinban
,kikaku
,kataban
,lotno
,seizobi
,shohikigen
,nisugatacd
,suryo
,tanicd
,tanka
,kazeikb
,shohizeiritsu
,choseishohizeigaku
,kingaku
,biko
,shanaibiko
,shiirekarikatakamokucd
,shiirekashikatakamokucd
,sakuseiuserid
,sakuseinichiji
,koshinuserid
,koshinnichiji
) select
currval('sqns_shiirerirekino')
,ms.shiireno
,ms.gyono
,ms.hatchushogyono
,ms.oyameisaicd
,ms.meisaicd
,ms.meisaikb
,ms.hinmokucd
,ms.hinmokumei
,ms.aitesakihinban
,ms.kikaku
,ms.kataban
,ms.lotno
,ms.seizobi
,ms.shohikigen
,ms.nisugatacd
,ms.suryo
,ms.tanicd
,ms.tanka
,ms.kazeikb
,ms.shohizeiritsu
,ms.choseishohizeigaku
,ms.kingaku
,ms.biko
,ms.shanaibiko
,ms.shiirekarikatakamokucd
,ms.shiirekashikatakamokucd
,ms.sakuseiuserid
,ms.sakuseinichiji
,ms.koshinuserid
,ms.koshinnichiji
from dat_m_shiire ms
where ms.shiireno = old.shiireno
;
return new;
end;
$$
LANGUAGE plpgsql;
