Informix Error -684
-684 Function <routine-name> returns too many values. </routine-name>
The number of returned values from a function is more than the number of values that the caller expects.
Example of error:
CREATE ROUTINE testroutine(arg INT) RETURNING INT, INT; RETURN 1,2; END ROUTINE
SELECT col FROM tab WHERE col = testroutine(1); -- error
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-684 fires when a routine is called in a context expecting a specific number of return values,
but the routine's RETURNING clause declares more values than that context can accept — per the
official guidance's example, a routine returning two values (INT, INT) called somewhere that
expects only one.
- A routine called inside an expression expecting a single scalar value, per the official
guidance's example, when the routine's
RETURNINGclause declares more than one value. - A routine's
RETURNINGclause widened during editing (adding a return value) without checking every call site still matches the new count. - The wrong routine called by name, where a similarly-named routine with a different
RETURNINGarity was invoked by mistake.
Solutions / Resolution
- Check the routine's
RETURNINGclause and compare its value count against the calling context's expectation. - Call the routine in a context that accepts all its declared return values, such as a
multi-variable
LETstatement, if the values are genuinely all needed:LET v_total, v_count = get_order_totals(p_customer_id); - Or use only the specific value needed by wrapping the call appropriately, if the calling context genuinely only wants one of several returned values — Informix doesn't support discarding extra return values inline, so this typically means assigning to a full set of variables and using only the one needed afterward.
Examples
The disallowed mismatch
CREATE FUNCTION get_order_totals(p_customer_id INT)
RETURNING INT, INT; -- total, count
...
END FUNCTION;
SELECT get_order_totals(customer_id) FROM customers;
-- -684: get_order_totals returns 2 values, this context expects 1
Corrected — accept all declared values
DEFINE v_total, v_count INT;
LET v_total, v_count = get_order_totals(42);
Diagnostic Checks
- Count the values in the routine's
RETURNINGclause and compare against how many the calling context (expression,LET,SELECT) actually expects.
Related Errors / Related Topics
- -655 — "RETURN value count does not match procedure declaration." A related return-count
error, checked at the routine's own
RETURNstatement against itsRETURNINGdeclaration, rather than at a caller. - -685 — "Function function-name returns too few values." The mirror-image situation: the caller expects more values than the routine returns.
- -686 — "Function function-name has returned more than one row." A related error, about
returning multiple rows (via
RETURN ... WITH RESUME) rather than too many values in one row.
Compare the routine's RETURNING clause's value count against what the specific call site
actually expects — not every context accepts multiple return values.