Informix Error -881: The resulting string length from CONCAT, LPAD, REPLACE or RPAD is longer than the maximum.
Cause and resolution
The resulting string length from CONCAT, LPAD, REPLACE or RPAD is longer than the maximum.
The LPAD, RPAD, REPLACE or CONCAT function returned a string whose length is outside the range from 1 to 255 bytes for NVARCHAR or VARCHAR, or from 1 to 32739 bytes for CHAR, NCHAR, or LVARCHAR. These functions return a string whose data type depends on the data type of the input string that the function is formatting. Make sure that the function returns a string whose length is within the size range for the returned data type.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-881 fires when CONCAT, LPAD, REPLACE, or RPAD produces a result string outside the
valid length range for the return type — per the official guidance, 1 to 255 bytes for
NVARCHAR/VARCHAR, or 1 to 32739 bytes for CHAR/NCHAR/LVARCHAR; the return type itself
is determined by the input string's own type.
CONCAT/LPAD/RPADcombining or padding strings to a result longer than the return type's maximum, per the official guidance — most likely when the return type resolves toVARCHAR/NVARCHAR(255-byte ceiling), the same ceiling behind -650.REPLACEsubstituting a much longer replacement text repeatedly, growing the result past the type's ceiling.- Padding to an unexpectedly large target length with
LPAD/RPAD, if the padding length argument was miscalculated.
Solutions / Resolution
- Confirm which data type the function's inputs resolve to, per the official guidance,
since that determines the applicable length ceiling (255 bytes for
VARCHAR/NVARCHAR, 32739 forCHAR/NCHAR/LVARCHAR). - Make sure the function's result stays within that type's size range, per the official
guidance — shorten the inputs, or cast to a wider type (
LVARCHAR) if the content genuinely needs to exceed 255 bytes.
Examples
Exceeding the VARCHAR ceiling
SELECT CONCAT(long_varchar_col1, long_varchar_col2) FROM documents;
-- -881: combined length exceeds 255 bytes for a VARCHAR result
Corrected — cast to a wider type first
SELECT CONCAT(long_varchar_col1::LVARCHAR(2000), long_varchar_col2::LVARCHAR(2000)) FROM documents;
Diagnostic Checks
- Identify the function's resolved return type (based on its input types), and check the actual result length against that type's specific ceiling.
Related Errors / Related Topics
- -650 — "Maximum varchar size has been exceeded." The same 255-byte
VARCHARceiling, hit via a column definition rather than a function result.
Identify the function's resolved return type first, since the length ceiling differs sharply
between VARCHAR/NVARCHAR (255 bytes) and CHAR/NCHAR/LVARCHAR (32739 bytes).