No, in Firebird 2.5 you can't specify the trigger to only run after some other trigger.
The execution order of triggers is determined by the order of statements that trigger them, ie if you use
INSERT INTO table2 ...
INSERT INTO table1 ...
then the (ON INSERT
) triggers of the table2
is executed before table1
ones. If table has more than one trigger of given type then the order is determined by the POSITION
clause of the trigger's declaration.
If you can't guarantee the order of INSERT
statements then perhaps you can use database trigger as a workaround - create an ON TRANSACTION COMMIT
trigger where you check for a flag you did set in the trigger2
. If the flag is there then execute the stuff which requires the data generated in the trigger2
. For setting up the flag you can use the RDB$SET_CONTEXT with the USER_TRANSACTION
namespace. Something like
CREATE TRIGGER trigger2 ACTIVE AFTER INSERT ON table2
AS
BEGIN
RDB$SET_CONTEXT ('USER_TRANSACTION', 'doTrigger1', 1);
END
CREATE TRIGGER trigger1 ACTIVE ON TRANSACTION COMMIT
AS
BEGIN
IF(RDB$GET_CONTEXT ('USER_TRANSACTION', 'doTrigger1') = 1)THEN BEGIN
-- proccess data
END
END
See the Firebirds language reference for the complete TRIGGER DDL syntax.