Informix Error -879: Trim character must be null or have a length of 1.
Cause and resolution
Trim character must be null or have a length of 1.
The TRIM function evaluated to NULL. However, the TRIM character value expression must be null or contain a single character. Your program is incorrectly written. Every time the TRIM function evaluates to NULL, the value your program inserts into the TRIM character value expression is not null or contains more than one character. Correct, recompile, and rerun your program.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-879 fires when TRIM's character-to-trim argument evaluates to something other than NULL or a
single character — per the official guidance, this specifically happens when the value supplied
by the program is neither NULL nor exactly one character long.
- A trim-character expression evaluating to a multi-character string, per the official
guidance — the direct, common cause;
TRIMexpects to strip one specific character, not a substring. - A trim-character value that's an empty string rather than NULL or a single character, a specific case of the same underlying rule.
- A variable intended to hold a single trim character populated incorrectly by upstream
logic in the program, producing an unexpected length at the point
TRIMevaluates it.
Solutions / Resolution
- Correct the program so the trim-character expression evaluates to NULL or a single character, per the official guidance — this is a program-logic fix, not a SQL syntax issue.
- Recompile and rerun the program, per the official guidance, once the trim-character value's source is corrected.
Examples
The disallowed multi-character trim value
TRIM(BOTH ' ' FROM ' hello '::VARCHAR(20));
-- -879: ' ' (two spaces) is not a single character
Corrected — a single character
TRIM(BOTH ' ' FROM ' hello '::VARCHAR(20));
Diagnostic Checks
- Trace the trim-character expression's actual value at the point of failure, confirming its length (should be exactly 1) or that it's genuinely NULL.
Related Errors / Related Topics
- -880 — "Trim character and trim source must be of string data type." A related
TRIMrestriction, about argument data types rather than the trim-character's length.
TRIM's character argument must be exactly one character (or NULL) — trace back to where the
program computed a longer value.