Informix Error -1320: A function has not returned the correct number of values expected by the calling function.
Cause and resolution
A function has not returned the correct number of values expected by the calling function.
If the function was invoked as part of an expression, then it returned more than one value. If a CALL invoked it, the number of expressions that follow the RETURN statement (in the function) was different from the number of variables that are listed in the RETURNING clause (in the CALL statement).
Check that the correct function was called. Review the logic of the function, especially its RETURN statements, to ensure that it always returns the expected number of values.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-1320 fires in two scenarios — per the official guidance: a function used within an expression
returns multiple values instead of one, or a CALL statement's RETURNING clause has a
different number of variables than the function's RETURN statement has expressions.
- A function used inside an expression that returns more than one value, per the official guidance's first named scenario — expressions expect exactly one value.
- A
CALL ... RETURNINGclause with a variable count that doesn't match the function'sRETURNexpression count, per the official guidance's second named scenario.
Solutions / Resolution
- Verify the correct function was invoked, per the official guidance — a naming collision or wrong overload could explain an unexpected return count.
- Review all
RETURNstatements to ensure they consistently return the expected quantity of values, per the official guidance.
Examples
A RETURNING clause with a mismatched count
FUNCTION get_order_info(p_order_id INT)
RETURN v_status, v_total;
END FUNCTION
CALL get_order_info(1) RETURNING v_status
-- -1320: get_order_info returns 2 values, RETURNING only captures 1
Corrected
CALL get_order_info(1) RETURNING v_status, v_total
Diagnostic Checks
- Count the values in the function's
RETURNstatement(s) and compare against how many the caller expects (an expression context expects exactly 1; aCALL ... RETURNINGclause's variable count must match exactly).
Related Errors / Related Topics
- -1317 — "A numeric conversion error has occurred..." A related function-call error, about type compatibility rather than return-value count.
- -1318 — "A parameter count mismatch has occurred..." A related function-call error, about argument count rather than return-value count.
The function's return-value count doesn't match what the caller expects — check RETURN
statements against the calling context.