Informix Error -9781: SLV cannot be an argument to a function invoked explicitly by EXECUTE or CALL.
Cause and resolution
SLV cannot be an argument to a function invoked explicitly by EXECUTE or CALL.
A routine that has an OUT parameter can only be invoked as part of a data-management language query (only in the WHERE clause). Do not invoke such a routine with a CALL or EXECUTE statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9781 fires when a routine with an OUT parameter is invoked via EXECUTE or CALL — per the official guidance.
- A routine with an OUT parameter invoked via EXECUTE/CALL instead of within a DML query's WHERE clause, per the official guidance — the direct, only cause; such routines can only be invoked as part of a data-manipulation-language query's WHERE clause.
Solutions / Resolution
- Don't invoke a routine with an OUT parameter using CALL or EXECUTE, per the official guidance — invoke it within a WHERE clause instead.
Examples
Invoking an OUT-parameter routine via EXECUTE
EXECUTE FUNCTION my_func(a, @out_var); -- -9781: my_func has an OUT parameter
Corrected
SELECT * FROM mytable WHERE my_func(a, @out_var);
Diagnostic Checks
- Check whether the routine invoked via EXECUTE/CALL has an OUT parameter, and rewrite the call to use a WHERE clause instead.
Related Errors / Related Topics
- -9780 — "Statement-local variable cannot be an argument to a function called from outside the WHERE clause." The same class of WHERE-clause-only restriction, general to SLV-accepting UDRs rather than specifically EXECUTE/CALL.
- -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 invocation method.
A routine with an OUT parameter was invoked via CALL/EXECUTE — invoke it in a WHERE clause instead.