22022ERRORTier 3 — Handle with care✅ HIGH confidenceindicator overflow
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
- 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.
Fix 1: Use a larger indicator variable type in ECPG
When using embedded SQL (ECPG) with indicator variables.
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