Informix Error -731
-731 Invalid use of column reference in trigger body.
For insert and delete triggers, the offending column is being used in the INTO clause of the EXECUTE PROCEDURE statement (which is only allowed for an update trigger). Remove the column names from the INTO clause.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-731 fires when an INSERT or DELETE trigger's EXECUTE PROCEDURE action includes an INTO
clause naming columns — per the official guidance, an INTO clause on the triggered action is
only meaningful for an UPDATE trigger, where it can receive the new column values; insert and
delete triggers don't have that kind of before/after column data to receive.
- An
INSERT/DELETEtrigger'sEXECUTE PROCEDUREaction written with anINTOclause, per the official guidance — copied from anUPDATEtrigger template without removing theINTOclause. - A misunderstanding of what
INTOdoes in a triggered action, expecting it to work the same way across all three trigger event types.
Solutions / Resolution
- Remove the column names from the
INTOclause, per the official guidance — forINSERT/DELETEtriggers, theEXECUTE PROCEDUREaction shouldn't have one at all. - If column values genuinely need to be passed to the procedure, pass them as arguments
instead, using the trigger's
REFERENCINGcorrelation name:CREATE TRIGGER trg_orders_insert INSERT ON orders REFERENCING NEW AS post FOR EACH ROW (EXECUTE PROCEDURE log_new_order(post.order_id, post.status));
Examples
The disallowed attempt
CREATE TRIGGER trg_orders_insert INSERT ON orders
REFERENCING NEW AS post FOR EACH ROW
(EXECUTE PROCEDURE log_new_order() INTO post.order_id);
-- -731: INTO isn't valid in an insert trigger's action
Corrected — pass values as arguments instead
CREATE TRIGGER trg_orders_insert INSERT ON orders
REFERENCING NEW AS post FOR EACH ROW
(EXECUTE PROCEDURE log_new_order(post.order_id));
Diagnostic Checks
- Check whether the trigger is
INSERT/DELETE(rather thanUPDATE) and whether itsEXECUTE PROCEDUREaction includes anINTOclause — the combination is what triggers this error.
Related Errors / Related Topics
- -729 — "Trigger has no triggered action." A related
CREATE TRIGGERstructural error, about a missing action rather than an invalidINTOclause on one. - -730 — "Cannot specify REFERENCING if trigger does not have FOR EACH ROW." A related
CREATE TRIGGERstructural error, aboutREFERENCING/FOR EACH ROWpairing.
INTO on a triggered action is UPDATE-trigger-only — remove it from INSERT/DELETE
triggers, passing values as ordinary procedure arguments instead.