SQLSTATE 22P02 ERROR Class 22: Data Exception

invalid_text_representation array value must start with “{” or dimension information — 22P02

PostgreSQL error "array value must start with "{" or dimension information" (SQLSTATE 22P02): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A string being cast to an array type was not formatted as a valid array literal. PostgreSQL raises SQLSTATE 22P02 (invalid_text_representation).

  • The array literal does not begin with a brace.
  • Array literals are enclosed in curly braces.
  • Common when passing comma-separated text without braces.

What the server log shows

ERROR:  array value must start with "{" or dimension information
LINE 1: SELECT '''1,2,3'''::int[];

Why PostgreSQL raises this — what the manual says

Section 8.15.2 Array Value Input:

“To represent arrays with other lower bounds, the array subscript ranges can be specified explicitly before writing the array contents.”

PostgreSQL parses array literals from a brace-enclosed grammar like '{1,2,3}' (optionally with a leading dimension spec). Input that doesn’t start with { or a dimension clause isn’t a valid array literal, so PostgreSQL reports 22P02.

Common causes

  • Passing '1,2,3' instead of '{1,2,3}'.
  • Omitting the curly braces around array elements.
  • Building the literal in application code without the brace syntax.

How to fix it

  1. Format the literal with braces: '{1,2,3}'::int[].
  2. Use the ARRAY[…] constructor: ARRAY[1,2,3].
  3. Quote string elements and escape special characters inside the braces.

Related & next steps

Reference: PostgreSQL 18 Section 8.15 “Arrays”.

Was this helpful?