22038
PostgreSQLERRORNotableData ExceptionHIGH confidence
singleton SQL/JSON item required
What this means
SQLSTATE 22038 is raised when a SQL/JSON context requires exactly one item (singleton) but the path expression returns multiple items or an array.
Why it happens
- 1A SQL/JSON function or operator that requires a single value receives a sequence or array from the path expression
How to reproduce
SQL/JSON singleton context with multiple matches.
expected output
ERROR: singleton SQL/JSON item required
Fix
Use a more specific path that returns exactly one item
WHEN When the context requires a singleton JSON value.
Why this works
Refine the JSON path expression to select a single element, or use jsonb_path_query() to handle multiple items as a set.
Version notes
Postgres 14+
SQL/JSON singleton requirement enforced from Postgres 14.
Sources
Official documentation ↗
Class 22 — Data Exception
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev