Subject on delete cascade
Author lobolo2000
Shouldn't FB2 delete master records after detail records if an 'on
delete cascade' clause is used (otherwise the referential integrity
would be violated)?

An example to illustrate the point:

CREATE EXCEPTION EX_ERROR 'Master record should be deleted after
detail record';

CREATE TABLE T1(
U1 BIGINT PRIMARY KEY);

CREATE TABLE T2(
U2 BIGINT PRIMARY KEY,
U3 BIGINT REFERENCES T1(U1) ON DELETE CASCADE);

SET TERM ^;

CREATE TRIGGER TR2 FOR T2
ACTIVE BEFORE DELETE POSITION 0 AS
BEGIN
IF (NOT EXISTS(SELECT U1 FROM T1 WHERE T1.U1=1)) THEN
EXCEPTION EX_ERROR;
END^

SET TERM ;^

COMMIT;

INSERT INTO T1 VALUES(1);

INSERT INTO T2 VALUES(1,1);

DELETE FROM T1;

COMMIT;

The exception is triggered! Any ideas?