Informix Error -9780: Statement-local variable cannot be an argument to a function called from outside the WHERE clause.
Cause and resolution
Statement-local variable cannot be an argument to a function called from outside the WHERE clause.
A user-defined routine (UDR) invocation that accepts a Statement Local Variable as an argument can be performed only in a WHERE clause of a Data Manipulation Language statement. This error results if this rule is violated. Move the UDR invocation inside a WHERE clause.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9780 fires when a UDR invocation accepting a Statement Local Variable (SLV) as an argument occurs outside a WHERE clause — per the official guidance.
- A UDR call accepting an SLV argument, placed outside the WHERE clause of a DML statement, per the official guidance — the direct, only cause; this is only permitted inside a WHERE clause.
Solutions / Resolution
- Move the UDR invocation inside a WHERE clause, per the official guidance.
Examples
An SLV-accepting UDR outside WHERE
SELECT foo(@my_slv) FROM mytable; -- -9780: foo takes an SLV but isn't in WHERE
Corrected
SELECT * FROM mytable WHERE foo(@my_slv);
Diagnostic Checks
- Check where the SLV-accepting UDR call appears in the statement, and move it into the WHERE clause.
Related Errors / Related Topics
- -9781 — "SLV cannot be an argument to a function invoked explicitly by EXECUTE or CALL." A related SLV-scope restriction, on EXECUTE/CALL rather than non-WHERE-clause placement.
- -9752 — "Argument must be a Statement Local Variable or SPL variable or argument for an OUT or INOUT parameter." A related SLV/OUT-INOUT restriction, on the argument's kind rather than the call's placement.
A UDR accepting an SLV argument was called outside a WHERE clause — move it inside one.