Subject | Transaction Context and Triggers |
---|---|
Author | Alan McDonald |
Post date | 2006-03-30T06:09:35Z |
I have tables with foreign keys into other tables.
In the context of one transaction:
1. insert into master
after insert trigger to insert into a log table
2. insert into child with PK of master
after insert trigger to insert into a log table
commit transaction
now - up til now, the sequence of insertion into the log table has reflected
the above sequence. If I order by the log table PK I see this same sequence.
but recently I see that it is possible to get the insertion into the log
table out of this sequence so the log table records an insertion to the
child sometimes before it records an insertion into the parent. This reverse
sequence is obviously not possible into the child first since it would
(does) raise an FK exception.
Q: am I crazy - seeing things?, OR is there never any guarantee of this
seqence within the context of the same transaction and I've been lucky up to
now, OR is there a way of ensuring this sequence somehow that I'm not aware
of?
regards
Alan McDonald
In the context of one transaction:
1. insert into master
after insert trigger to insert into a log table
2. insert into child with PK of master
after insert trigger to insert into a log table
commit transaction
now - up til now, the sequence of insertion into the log table has reflected
the above sequence. If I order by the log table PK I see this same sequence.
but recently I see that it is possible to get the insertion into the log
table out of this sequence so the log table records an insertion to the
child sometimes before it records an insertion into the parent. This reverse
sequence is obviously not possible into the child first since it would
(does) raise an FK exception.
Q: am I crazy - seeing things?, OR is there never any guarantee of this
seqence within the context of the same transaction and I've been lucky up to
now, OR is there a way of ensuring this sequence somehow that I'm not aware
of?
regards
Alan McDonald