Informix Error -476
-476 The LENGTH field must be specified when the type is SQLCHAR.
When you use a SET DESCRIPTOR statement, and TYPE is set to SQLCHAR, the LENGTH field must also be specified and set in the same SET DESCRIPTOR statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-476 is another X/Open SET DESCRIPTOR field-pairing rule, similar in spirit to -475: when
TYPE is set to SQLCHAR, the LENGTH field must also be specified in the same statement —
SQLCHAR is a variable-length-capable type, so the server needs an explicit length rather than
inferring one.
- A
SET DESCRIPTORstatement settingTYPE = SQLCHARwithout also settingLENGTH— the direct, only cause. - Code assuming a default or implicit length applies, when
SQLCHARspecifically requires it to be stated explicitly.
Solutions / Resolution
- Specify the
LENGTHfield wheneverTYPEis set toSQLCHAR, per the official guidance, within the sameSET DESCRIPTORstatement. - Determine the correct length value from the actual column/host-variable definition being described, rather than guessing or using a placeholder.
Examples
Setting LENGTH alongside TYPE = SQLCHAR
SET DESCRIPTOR 'desc1' VALUE 1 TYPE = SQLCHAR, LENGTH = 50;
The disallowed omission
SET DESCRIPTOR 'desc1' VALUE 1 TYPE = SQLCHAR;
-- -476: LENGTH must also be specified
Diagnostic Checks
- Check whether
TYPE = SQLCHARis set in the failing statement. - Confirm
LENGTHis also specified in the same statement, with an appropriate value.
Related Errors / Related Topics
- -475 — "In a GET statement, if DATA is null, then INDICATOR must be specified." A related
X/Open descriptor field-pairing rule, in a
GET DESCRIPTORcontext instead ofSET DESCRIPTOR. - -474 — "Unknown field type." Another related X/Open descriptor-field restriction, about valid field type keywords generally.
SQLCHAR always needs an explicit LENGTH in the same SET DESCRIPTOR statement — there's no
default or inferred value for this specific type.