Informix Error -1310: Exiting the current function without executing a RETURN statement.
Cause and resolution
Exiting the current function without executing a RETURN statement.
The current function does not return void but is about to exit without executing a RETURN statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-1310 fires when a 4GL function that isn't declared void reaches its end (or an exit path)
without executing a RETURN statement — per the official guidance, a non-void function must
return a value before exiting.
- A code path through the function that doesn't reach a
RETURNstatement, per the official guidance — the direct, only cause, commonly a conditional branch or error-handling path that falls through to the function's end. - A function whose declared return type doesn't actually match its intended use (should
have been
void), less commonly, if no meaningful value is ever produced.
Solutions / Resolution
- Add a
RETURNstatement to every exit path of the function, per the official guidance — including error-handling branches and any fall-through end of the function body. - If the function genuinely doesn't need to return a value, declare it appropriately, if the function's own signature/type allows a void-style declaration.
Examples
A branch missing a RETURN
FUNCTION get_status(p_order_id INT)
DEFINE v_status CHAR(10);
IF p_order_id > 0 THEN
LET v_status = "found";
RETURN v_status;
END IF
-- -1310: falls through here with no RETURN if p_order_id <= 0
END FUNCTION
Corrected
FUNCTION get_status(p_order_id INT)
DEFINE v_status CHAR(10);
IF p_order_id > 0 THEN
LET v_status = "found";
ELSE
LET v_status = "not found";
END IF
RETURN v_status;
END FUNCTION
Diagnostic Checks
- Trace every exit path through the function, including conditional branches and error
handlers, and confirm each one reaches a
RETURNstatement.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -1310 in this set yet.
A code path through the function reaches its end without a RETURN — trace every exit path and
add the missing RETURN.