Informix Error -741: Trigger for the same event already exists.
Cause and resolution
Trigger for the same event already exists.
You are creating a trigger for an event, but another trigger already exists for that event. You can have only one insert or delete trigger on a table. If you are defining multiple triggers that occur on an update, the column lists in the UPDATE statements must be mutually exclusive. You cannot name a column as a triggering column in more than one UPDATE clause.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-741 fires when CREATE TRIGGER defines a trigger for an event a table already has one for — per
the official guidance, a table can have only one INSERT trigger and only one DELETE trigger;
for UPDATE triggers, multiple are allowed only if each one's triggering column list is mutually
exclusive of the others.
- A second
INSERTtrigger attempted on a table that already has one, per the official guidance — only one is allowed, full stop. - A second
DELETEtrigger attempted on a table that already has one, per the official guidance — same restriction. - A second
UPDATEtrigger whose triggering column list overlaps with an existingUPDATEtrigger's list, per the official guidance — multipleUPDATEtriggers are allowed, but only with non-overlapping column lists; the same column can't be named as a triggering column in more than oneUPDATE OF (...)clause.
Solutions / Resolution
- Consolidate logic into the single existing
INSERT/DELETEtrigger, per the official guidance, rather than attempting a second one — combine both triggers' actions into one trigger's action list. - For
UPDATEtriggers, ensure each trigger'sUPDATE OF (...)column list doesn't overlap with any otherUPDATEtrigger's list, per the official guidance — split the columns across triggers so each column appears in only one. - Query
systriggersfor existing triggers on the table before adding a new one:SELECT trigname, event FROM systriggers WHERE tabid = (SELECT tabid FROM systables WHERE tabname = 'orders');
Examples
A second INSERT trigger
CREATE TRIGGER trg_orders_insert_1 INSERT ON orders ...;
CREATE TRIGGER trg_orders_insert_2 INSERT ON orders ...;
-- -741: orders already has an INSERT trigger
Overlapping UPDATE triggering columns
CREATE TRIGGER trg_status_change UPDATE OF status ON orders ...;
CREATE TRIGGER trg_status_and_ship UPDATE OF status, ship_date ON orders ...;
-- -741: 'status' is a triggering column in both UPDATE triggers
Corrected — non-overlapping UPDATE column lists
CREATE TRIGGER trg_status_change UPDATE OF status ON orders ...;
CREATE TRIGGER trg_ship_change UPDATE OF ship_date ON orders ...;
Diagnostic Checks
- Query
systriggersfor the table's existing triggers and their events, and forUPDATEtriggers specifically, check the triggering column lists for overlap.
Related Errors / Related Topics
- -742 — "Trigger and cascading-delete referential constraint cannot coexist." A related trigger-restriction error, about delete triggers versus cascading foreign keys rather than multiple triggers on the same event.
Only one INSERT/DELETE trigger per table; multiple UPDATE triggers are fine as long as
their triggering column lists don't overlap.