Informix Error -4082: Operands of MATCH and LIKE operations must be of CHAR or VARCHAR type.
Cause and resolution
Operands of MATCH and LIKE operations must be of CHAR or VARCHAR type.
This statement uses the MATCH or LIKE operator with an argument expression that is numeric or binary. No automatic conversion of data types exists in this case. Examine the expression. If it is written as you intended, revise it to assign the values to character variables (thus forcing their conversion to character) before you use them with MATCH or LIKE.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4082 fires when MATCH or LIKE is used with a numeric or binary argument expression — per
the official guidance, no automatic type conversion happens in this case.
- A numeric or binary expression used as an operand of
MATCH/LIKE, per the official guidance — the direct, only cause.
Solutions / Resolution
- Examine the expression, per the official guidance.
- If it's as intended, assign the values to character variables first (forcing
conversion to character) before using them with
MATCH/LIKE, per the official guidance.
Examples
A numeric operand with LIKE
DEFINE qty INTEGER
IF qty LIKE "1%" THEN
-- -4082: qty is INTEGER, not CHAR/VARCHAR
END IF
Corrected
DEFINE qty_str CHAR(10)
LET qty_str = qty
IF qty_str LIKE "1%" THEN
...
END IF
Diagnostic Checks
- Check every
MATCH/LIKEoperand's data type, and convert to a character variable first if it's numeric or binary.
Related Errors / Related Topics
- -4075 — "Simple string expressions must have type CHAR or VARCHAR." A related
string-type requirement, about simple string expressions generally rather than
MATCH/LIKEoperands specifically.
A MATCH/LIKE operand is numeric or binary — assign it to a CHAR/VARCHAR variable first.