@ create trigger avbokad after delete on Bokning referencing old table as o for each statement begin atomic declare platsnummer integer; declare passagerarnummer integer; declare vantelistenummer integer; select Plats into platsnummer from o; select Nummer, Passagerare into vantelistenummer, passagerarnummer from Vantelista where Nummer = (select min(Nummer) from Vantelista); insert into Bokning (Plats, BokadAv) select o.Plats, Vantelista.Passagerare from o, Vantelista where Vantelista.Nummer = (select min(Nummer) from Vantelista); delete from Vantelista where Nummer = vantelistenummer; end @
Det finns en del onödig kod i triggern ovan. Vad kan man ta bort?