Informix Error -9062: An error has occurred during the conversion of a numeric value to a CHARACTER type user variable. The CHARACTER type variable is not long enough to hold the result.
Cause and resolution
An error has occurred during the conversion of a numeric value to a CHARACTER type user variable. The CHARACTER type variable is not long enough to hold the result.
The conversion of a numeric value to character produced more numeric characters than the destination could hold. Rather than truncate the result, ACEGO stops with an error. You can either redefine the destination variable, or you can limit the size of the converted value (for example, with a USING format string).
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9062 fires when converting a numeric value to a CHARACTER-type user variable produces more characters than the destination can hold — per the official guidance.
- A CHARACTER destination variable too short for the converted numeric value, per the official guidance — the direct, only cause; ACEGO stops rather than truncate the result.
Solutions / Resolution
- Redefine the destination variable to a sufficient length, per the official guidance.
- Limit the size of the converted value, for example with a USING format string, per the official guidance.
Examples
An oversized numeric-to-character conversion
DEFINE result CHAR(5)
LET result = amount -- -9062: amount converts to more than 5 characters
Corrected
DEFINE result CHAR(12)
LET result = amount USING "#####.##"
Diagnostic Checks
- Check the destination variable's defined length against the maximum width the numeric conversion could produce, and widen the variable or constrain the value with USING.
Related Errors / Related Topics
- -9049 — "A value entered as a command line parameter cannot be converted to the data type type." A related type-conversion error, on command-line parameters rather than numeric-to-CHARACTER assignment.
A numeric-to-CHARACTER conversion produced more characters than the destination variable could hold — widen the variable or constrain the value with USING.