2200B
PostgreSQLERRORNotableData ExceptionHIGH confidence
escape character conflict
What this means
SQLSTATE 2200B is raised when an escape character specified in a LIKE or SIMILAR TO pattern conflicts with the pattern syntax — for example, using the wildcard character itself as the escape character.
Why it happens
- 1Using a LIKE ESCAPE clause where the escape character is the same as a special pattern character (% or _)
How to reproduce
LIKE with a conflicting escape character.
trigger — this will error
trigger — this will error
SELECT * FROM items WHERE name LIKE '50%' ESCAPE '%'; -- % cannot be both wildcard and escape
expected output
ERROR: invalid escape character
Fix
Use a neutral escape character such as backslash
WHEN When escaping wildcards in LIKE patterns.
Use a neutral escape character such as backslash
SELECT * FROM items WHERE name LIKE '50\%' ESCAPE '\';
Why this works
Backslash is the conventional escape character and does not conflict with the LIKE wildcards % and _.
Sources
Official documentation ↗
Class 22 — Data Exception
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev