HI.

With Interbase it is a breeze to do cascade deletes using triggers because
of IB's concept of New and Old.

With SQL7 it seems nobody thought of this, because the delete is attempted
BEFORE the trigger is called.

Consider: T1 is parent, T2 is Child with FK constraint to T1
If I write a simple trigger. The PK for T1 is called T1ID

create trigger DelT1 on T1
  for delete as
  declare @T1ID int
begin
  /* now casacade */

  select @T1ID = T1IDSecurityGroupID from Deleted;
  delete from T2 where T2ID = @T1ID;
end

When I execute Delete from T1 where T1ID = 3

I allways get the FK Constraint Violation, and my delete trigger is not
called.

QUESTION

How do I get a delete trigger to run before SQL7 actually does the delete,
or How do others handle cascade deletes in SQL7?

TIA,

Tony.

---------------------------------------------------------------------------
  New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to