value out of range: overflow

SQLSTATE 22003 condition numeric_value_out_of_range class 22 — Data Exception severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.

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).

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

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”.