SQLSTATE 2203FSeverity lowLab verified

Incident brief

JSON_VALUE must return a single scalar

JSON_VALUE must resolve to a single scalar; a path that returns an array, object, or multiple items raises this data exception — use JSON_QUERY for non-scalars.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
JSON_VALUE must return a single scalar
What triggers it
Call JSON_VALUE(doc, path) where the path returns an array, object, or multiple items rather than one scalar.
The fix
Point the path at a single scalar (an element like $[0] rather than the whole array).
Proof
Reproduced on PostgreSQL 18.4 → A single SELECT reproduces SQLSTATE 2203F; a non-scalar path result is rejected by JSON_VALUE.

The fix

What to do right now

The immediate, application-level response to this error.

  • Point the path at a single scalar (an element like $[0] rather than the whole array).
  • Use JSON_QUERY instead of JSON_VALUE when you intend to return an array or object.
Fix — SQL
-- JSON_VALUE returns one scalar; select a scalar element.
SELECT JSON_VALUE('[1,2]'::jsonb, '$[0]' RETURNING int ERROR ON ERROR);

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed