Subject trigger question
Author Datatal AB - Gauffin, Jonas
Hello

I got a trigger (before delete) on a table called bokning. I got a identical table called bokning_historik that all old entries should be moved to by the trigger. I also got a table called bokning_passagerare that contains all passagers from the booking. (and a table called bokning_passagerare_historik).

bokning_passagerare.bokningsnr is a FK to bokning.bokningsnr
bokning_passagerare_historik.bokningsnr is a FK to bokning_historik.bokningsnr

bokning before delete trigger looks like this:
-------------
insert into bokning_historik (bokningsnr, flight_nr, avg_datum, bokad_av, faktura_adress)
values(old.bokningsnr, old.flight_nr, old.avg_datum, old.bokad_av, old.faktura_adress);

insert into bokning_passagerare_historik (bokningsnr, platsnr, personnr, pris, prisnamn)
select bokningsnr, platsnr, personnr, pris, prisnamn
from bokning_passagerare where bokningsnr=old.bokningsnr ;

delete from bokning_passagerare where bokningsnr = old.bokningsnr;
---------------

it fails on bokning_passagerare_historik insert as if nothing have been inserted into bokning_historik.

well. I can move some of the statements to a bokning_passagerare trigger, but then I gotto check if the booking exist in bokning_historik and just discard the passagerrow if it doesnt.


[Non-text portions of this message have been removed]