Subject | Trigger order |
---|---|
Author | Valdir Stiebe Junior |
Post date | 2003-02-05T13:25:01Z |
Hi,
I have two tables in a 1 - N relationship creating a Master-Detail. And have
to update a third table on the detail after delete in some cases depending
the Master status field. So i did:
create trigger .... after delete ... on detail table...
...
begin
select STATUS from MASTER ... into ...
if STATUS = SBRINGLE then
update THIRD_TABLE...
end
But, when deleting the MASTER record and by cascade delete the DETAILS....
the select STATUS statement returns NULL i think that is because the MASTER
was deleted...
The order in this case shouldn't be
1.before delete MASTER
2.before delete DETAILS
3.delete DETAILS
4.after delete DETAILS
5.delete MASTER
6.after delete MASTER
To avoid this problem i've created a trigger before delete on MASTER table
that delete the details before master is gone.
I have two tables in a 1 - N relationship creating a Master-Detail. And have
to update a third table on the detail after delete in some cases depending
the Master status field. So i did:
create trigger .... after delete ... on detail table...
...
begin
select STATUS from MASTER ... into ...
if STATUS = SBRINGLE then
update THIRD_TABLE...
end
But, when deleting the MASTER record and by cascade delete the DETAILS....
the select STATUS statement returns NULL i think that is because the MASTER
was deleted...
The order in this case shouldn't be
1.before delete MASTER
2.before delete DETAILS
3.delete DETAILS
4.after delete DETAILS
5.delete MASTER
6.after delete MASTER
To avoid this problem i've created a trigger before delete on MASTER table
that delete the details before master is gone.