22027
PostgreSQLERRORCriticalData ExceptionHIGH confidence

trim error

What this means

SQLSTATE 22027 is raised when arguments to the TRIM function are invalid. In practice this is rarely seen in Postgres as TRIM accepts a wide range of inputs.

Why it happens
  1. 1Invalid combination of arguments to the SQL-standard TRIM function
How to reproduce

TRIM function with invalid arguments.

expected output

ERROR:  trim error

Fix

Use correct TRIM syntax

WHEN When this error appears.

Use correct TRIM syntax
SELECT TRIM(BOTH ' ' FROM '  hello  '); -- valid form
SELECT LTRIM('  hello  ');                 -- Postgres extension

Why this works

TRIM accepts LEADING, TRAILING, or BOTH as the trim direction, followed by FROM and the target string.

Sources
Official documentation ↗

Class 22 — Data Exception

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors