numeric field 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 value exceeds the precision/scale declared for a numeric(p,s) column. PostgreSQL raises SQLSTATE 22003 (numeric_value_out_of_range) with a DETAIL describing the allowed precision.

What the server log shows

ERROR:  numeric field overflow
DETAIL:  A field with precision 5, scale 2 must round to an absolute value less than 10^3.

Why PostgreSQL raises this — what the manual says

Section 8.1.2 Arbitrary Precision Numbers:

“Then, if the number of digits to the left of the decimal point exceeds the declared precision minus the declared scale, an error is raised.”

numeric(p,s) allows p-s digits before the decimal point. A value needing more integer digits cannot be represented and fails with 22003 (fractional excess is rounded, but integer-part excess errors).

Common causes

How to fix it

  1. Increase precision: ALTER TABLE t ALTER COLUMN amount TYPE numeric(12,2);.
  2. Validate the value range before insert.
  3. Round/scale intentionally if the extra magnitude is unexpected.

Related & next steps

Reference: PostgreSQL 18 Section 8.1 “Numeric Types”.