Informix Error -4142: Functions called in the WHENEVER statement cannot require parameters.
Cause and resolution
Functions called in the WHENEVER statement cannot require parameters.
The WHENEVER statement in the program has the form WHENEVER condition CALL function, and the function being called is declared to have parameters. The function call in this context cannot even have parentheses, let alone arguments. Note that main has implicit parameters, so it cannot be used in this form of the WHENEVER statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4142 fires when a WHENEVER condition CALL function statement names a function declared with
parameters — per the official guidance, the function call in this context can't even have
parentheses, let alone arguments; note that main has implicit parameters and so can't be
used here either.
- The function named in
WHENEVER ... CALLis declared with parameters, per the official guidance — the direct, only cause.
Solutions / Resolution
- Use a function with no parameters in the
WHENEVER ... CALLstatement.
Examples
A WHENEVER CALL to a function with parameters
WHENEVER ERROR CALL handleError(errno)
-- -4142: no parentheses or arguments are allowed here
Corrected
WHENEVER ERROR CALL handleError
Diagnostic Checks
- Check the function named in every
WHENEVER ... CALLstatement, and confirm it takes no parameters (and isn'tmain).
Related Errors / Related Topics
- -4143 — "Functions called in the WHENEVER statement cannot return values." A closely
related
WHENEVER ... CALLrestriction, about the function's return value rather than its parameters.
A WHENEVER ... CALL function is declared with parameters, which isn't allowed — use a
parameterless function.