Informix Error -19825: Cannot use WHEN clause if INSTEAD OF trigger is defined.
Cause and resolution
Cannot use WHEN clause if INSTEAD OF trigger is defined.
You cannot use the WHEN clause with INSTEAD OF triggers since you cannot specify trigger restrictions for INSTEAD OF trigger statements. The trigger will always replace the specified action.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-19825 fires when a WHEN clause is used with an INSTEAD OF trigger — per the official
guidance. INSTEAD OF triggers can't have restrictions; the trigger always replaces the
specified action.
- A
WHENclause used with anINSTEAD OFtrigger, per the official guidance — the direct, only cause.
Solutions / Resolution
- Remove the
WHENclause from theINSTEAD OFtrigger definition, per the official guidance.
Examples
An INSTEAD OF trigger with a WHEN clause
CREATE TRIGGER mytrig INSTEAD OF INSERT ON myview
REFERENCING NEW AS n
WHEN (n.col1 > 0)
FOR EACH ROW (...);
Corrected
CREATE TRIGGER mytrig INSTEAD OF INSERT ON myview
REFERENCING NEW AS n
FOR EACH ROW (...);
Diagnostic Checks
- Check the
INSTEAD OFtrigger definition for aWHENclause, and remove it.
Related Errors / Related Topics
- -19823 — "Cannot use EXECUTE PROCEDURE INTO with the INSTEAD OF trigger." A related
INSTEAD OF-trigger restriction, about the action rather than theWHENclause. - -19824 — "Cannot use BEFORE or AFTER action with INSTEAD OF trigger." A related
INSTEAD OF-trigger restriction, about timing rather than theWHENclause.
WHEN can't be used with an INSTEAD OF trigger — remove it.