Informix Error -732
-732 Incorrect use of old or new values correlation name inside trigger.
You cannot use the new or old correlation name outside the FOR EACH ROW section or in the INTO clause of the EXECUTE PROCEDURE statement. You cannot use the new or old correlation name to qualify the SELECT COUNT DISTINCT column. For example, the following statement returns this error:
SELECT COUNT (DISTINCT oldname.colname)
You cannot specify an old correlation name for an insert trigger. You cannot specify a new correlation name for a delete trigger.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-732 covers several distinct misuses of a trigger's OLD/NEW correlation name, per the
official guidance: using it outside the FOR EACH ROW section, using it in the EXECUTE PROCEDURE action's INTO clause, using it to qualify a SELECT COUNT(DISTINCT ...) column, an
INSERT trigger specifying an old correlation name, or a DELETE trigger specifying a new
correlation name.
- The correlation name referenced outside
FOR EACH ROW, per the official guidance — it's only meaningful within the row-level action section. - The correlation name used in an
INTOclause, per the official guidance — the same restriction area as -731, but here about the correlation name specifically rather than a plain column. - The correlation name used to qualify a
SELECT COUNT(DISTINCT column)argument, per the official guidance's specific example —SELECT COUNT(DISTINCT oldname.colname)is disallowed outright. - An
INSERTtrigger declaring anOLDcorrelation name, per the official guidance — an inserted row has no "old" state, so this isn't meaningful. - A
DELETEtrigger declaring aNEWcorrelation name, per the official guidance — a deleted row has no "new" state, the mirror-image restriction.
Solutions / Resolution
- Move the correlation-name reference inside the
FOR EACH ROWsection, if it was used outside it. - Remove the correlation name from any
INTOclause, per -731's resolution. - Rewrite
COUNT(DISTINCT oldname.colname)-style expressions to avoid qualifying theDISTINCTargument with the correlation name — reference the column without the correlation prefix if the query's context makes it unambiguous, or restructure the aggregate. - Remove
REFERENCING OLDfromINSERTtriggers, per the official guidance — onlyNEWis meaningful there. - Remove
REFERENCING NEWfromDELETEtriggers, per the official guidance — onlyOLDis meaningful there.
Examples
An OLD correlation name on an INSERT trigger
CREATE TRIGGER trg_orders_insert INSERT ON orders
REFERENCING OLD AS pre NEW AS post FOR EACH ROW
(EXECUTE PROCEDURE log_new_order(post.order_id));
-- -732: an INSERT trigger has no "old" row; OLD isn't valid here
Corrected
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
- Identify which of the five documented misuses applies: outside
FOR EACH ROW, insideINTO, qualifyingCOUNT(DISTINCT ...),OLDon anINSERTtrigger, orNEWon aDELETEtrigger.
Related Errors / Related Topics
- -730 — "Cannot specify REFERENCING if trigger does not have FOR EACH ROW." A related
REFERENCING/FOR EACH ROWstructural restriction. - -731 — "Invalid use of column reference in trigger body." A related restriction on
INTOclause usage, for plain columns rather than correlation names specifically. - -734 — "Object name matches old or new values correlation name." A related
REFERENCINGrestriction, about a naming collision rather than a usage-context misuse.
Five distinct misuse patterns share this one message — match the specific symptom (event type mismatch, INTO usage, COUNT DISTINCT qualification, or scope) to the right fix.