PG
PRO
22022ERRORTier 3 — Handle with care✅ HIGH confidence

indicator overflow

Category: Data ExceptionVersions: All Postgres versions

What this means

SQLSTATE 22022 is a standard SQL code raised when an indicator variable overflows. In Postgres this is uncommon in practice and mainly applies to embedded SQL (ECPG) contexts where indicator variables track NULL status and string lengths.

Why it happens

  1. 1In ECPG (embedded C SQL), an indicator variable is too small to hold the actual length of the retrieved string

How to reproduce

ECPG program retrieving a long string with an undersized indicator variable.

trigger — this will ERROR
ERROR: indicator variable value is out of range

Fix 1: Use a larger indicator variable type in ECPG

When using embedded SQL (ECPG) with indicator variables.

fix

Why this works

Declare the indicator variable as a long or ensure it can hold the maximum string length returned by the query.

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

🔧 Source ref: Class 22 — Data Exception

Confidence assessment

✅ HIGH confidence

Standard SQLSTATE primarily relevant to ECPG embedded SQL. Rarely seen in application-level Postgres use.

See also

🔗 Related errors

📄 Reference pages

ECPG — Embedded SQL in C
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →