SQLSTATE 22003 ERROR Class 22: Data Exception

numeric_value_out_of_range value out of range: overflow — 22003

PostgreSQL error "value out of range: overflow" (SQLSTATE 22003): 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 numeric computation or conversion produced a value larger than the target type can hold. PostgreSQL raises SQLSTATE 22003 (numeric_value_out_of_range).

  • Arithmetic result exceeds the type’s maximum.
  • Common with multiplication/addition near the type’s limit.
  • Also seen casting a large value into a narrower type.

What the server log shows

ERROR:  value out of range: overflow

Why PostgreSQL raises this — what the manual says

Section 8.1.3 Floating-Point Types:

“Values that are too large or too small will cause an error.”

Each numeric type has a fixed range. When an operation or cast produces a value beyond that range, it cannot be represented and PostgreSQL reports 22003 rather than silently wrapping.

Common causes

  • Arithmetic exceeding the type’s maximum.
  • Casting a large value into a smaller type.
  • Accumulating sums that overflow an integer type.

How to fix it

  1. Use a wider type (e.g. bigint or numeric).
  2. Cast intermediate results to numeric to avoid integer overflow.
  3. Validate input ranges before computation.

Related & next steps

Reference: PostgreSQL 18 Section 8.1 “Numeric Types”.

Was this helpful?