Subject RE: DML in triggers
Author Chris Wallis
>
>I had a Before Update trigger that included a statement like:
>delete from ATable where SomeField=Somevalue
>embedded in a trigger on ATable. This was causing the database to be
corrupted.

This was the code causing the problem:
if (
(new.sec_id <> old.sec_id) and
(new.hldg_seqno < 0)
) then
delete from holdings
where
old.sec_id = sec_id and
old.hsd_doc_id = hsd_doc_id and
hldg_seqno < 0;
else begin
...

The application compares a current document to a previous document, based on
the SEC_ID field. In the case of matching pairs between the two documents,
differences are computed on numeric fields. BUT, if the previous document
contains a SEC_ID that is not present in the current document, a
place-holder record is created that shows that the SEC_ID (security) in the
previous document has been liquidated.

The code above is intended to delete any placeholder records under the old
SEC_ID, since they are no longer needed.

Firebird version 1.5.2 Superserver on Windows NT4 SP6

Sean, SET, Nando, thanks for your help.