Informix Error -733
-733 Cannot reference procedure variable in CREATE TRIGGER or CREATE VIEW
statement.You have a CREATE TRIGGER or CREATE VIEW statement inside an SPL routine, and within the CREATE TRIGGER or CREATE VIEW statement, you reference a variable that is defined in the SPL routine. This action is not legal. Remove the reference to the SPL-routine variable from the CREATE TRIGGER or CREATE VIEW statement and try again.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-733 fires when a CREATE TRIGGER or CREATE VIEW statement written inside an SPL routine
references a variable defined in that routine — per the official guidance, this isn't legal,
since a trigger or view definition must stand on its own (the same underlying principle as
-546's host-variable restriction on views) rather than depending on a routine's local state.
- A
CREATE VIEWinside a routine referencing one of the routine's ownDEFINEd variables, per the official guidance — the direct, only cause for the view case. - A
CREATE TRIGGERinside a routine referencing one of the routine's own variables, the same restriction for the trigger case. - A variable used to parameterize what should have been literal SQL, assuming the trigger/view definition could pick up the variable's current value at creation time and treat it as fixed thereafter — the definition mechanism doesn't support this.
Solutions / Resolution
- Remove the reference to the SPL-routine variable, per the official guidance, from the
CREATE TRIGGER/CREATE VIEWstatement, and retry. - Use a literal value instead, if the variable's value at the time of creation was meant to
become a fixed part of the definition — build the
CREATE TRIGGER/CREATE VIEWstatement text dynamically (e.g. viaEXECUTE IMMEDIATEwith string concatenation) if the value genuinely needs to vary based on the routine's input.
Examples
The disallowed attempt
CREATE PROCEDURE make_recent_orders_view(p_days INT)
CREATE VIEW recent_orders AS
SELECT * FROM orders WHERE order_date > TODAY - p_days;
-- -733: p_days is an SPL-routine variable, not a legal reference here
END PROCEDURE;
Corrected — build the statement dynamically instead
CREATE PROCEDURE make_recent_orders_view(p_days INT)
DEFINE v_stmt VARCHAR(200);
LET v_stmt = 'CREATE VIEW recent_orders AS SELECT * FROM orders WHERE order_date > TODAY - '
|| p_days;
EXECUTE IMMEDIATE v_stmt;
END PROCEDURE;
Diagnostic Checks
- Scan
CREATE TRIGGER/CREATE VIEWstatements inside routines for references to the routine's ownDEFINEd variables, and either remove the reference or switch to building the statement dynamically.
Related Errors / Related Topics
- -546 — "Cannot have host variables when creating a view view-name." A related restriction,
on host variables in a view's
SELECT(in embedded SQL generally) rather than SPL-routine variables specifically.
A trigger or view definition must stand alone — build the statement dynamically via
EXECUTE IMMEDIATE if a routine's variable value genuinely needs to shape it.