Informix Error -9752: Argument must be a Statement Local Variable or SPL variable or argument for an OUT or INOUT parameter.
Cause and resolution
Argument must be a Statement Local Variable or SPL variable or argument for an OUT or INOUT parameter.
UDRs with OUT/INOUT parameters cannot be used in the WHERE clause of a SELECT statement unless the OUT/INOUT parameters are defined as Statement Local Variables (SLV). For example
SELECT * FROM mytable WHERE foo (arg1, arg2, inout1, inout2, ...., inoutn) ; is not a valid syntax assuming that foo is a UDR which has OUT/INOUT parameters denoted by inout1...inoutn above. To use UDR foo in the WHERE clause the above example must be modified to
SELECT myslv1 , ..., myslvN, * FROM mytable WHERE foo (arg1, arg2, myslv1 # svlDataType1, ..., myslvN # svlDataTypeN);
myslv1, ..., myslvN are the SLVs defined for the OUT/INOUT parameters with return datatype svlDataType1, ..., svlDataTypeN respectively. Please note that it is optional to use the SLVs in the projection list for the SELECT statement.
You can invoke an SPL routine or a C UDR with OUT or INOUT parameters within a routine written in SPL. The parameter you pass into the OUT or INOUT parameter must be either an SPL variable or a parameter from another SPL routine, and the parameter cannot be passed as any form of expression.
Example: create procedure p1(inout in1 integer); define a int; let a = in1; let in1 = a + 1; end procedure;
create function f1(in1 integer) returning integer; call p1(in1); return in1; end function;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9752 fires when a UDR with OUT/INOUT parameters is called in a SELECT statement's WHERE clause without the OUT/INOUT arguments being Statement Local Variables — per the official guidance.
- A UDR with OUT/INOUT parameters called in a WHERE clause using non-SLV arguments for those parameters, per the official guidance — the direct, only cause; UDRs with OUT/INOUT parameters can't be used in a WHERE clause unless those parameters are bound to Statement Local Variables (SLVs).
Solutions / Resolution
- Bind the OUT/INOUT arguments to Statement Local Variables, per the official guidance, when calling such a UDR in a WHERE clause.
Examples
An invalid WHERE-clause call
SELECT * FROM mytable
WHERE foo(arg1, arg2, inout1, inout2); -- -9752: inout1/inout2 aren't SLVs
Corrected — using Statement Local Variables
SELECT * FROM mytable
WHERE foo(arg1, arg2, @inout1, @inout2);
Diagnostic Checks
- Check the WHERE clause for a UDR call with OUT/INOUT parameters, and bind those
arguments to Statement Local Variables (
@varnamesyntax).
Related Errors / Related Topics
- -9714 — "OUT parameter can only be the last parameter of a routine." A related OUT-parameter restriction, on the routine's definition rather than its use in a WHERE clause.
- -9715 — "A procedure cannot have any OUT parameters." A related OUT-parameter restriction, on procedures being disallowed OUT parameters entirely.
A UDR with OUT/INOUT parameters was called in a WHERE clause without Statement Local Variables — bind those arguments to SLVs.