value “…” is out of range for type bigint

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 11 Jun 2026 · Reproduced live with the SQL on this page.

Symptoms

A textual value was too large (or small) to fit a bigint during conversion. PostgreSQL raises SQLSTATE 22003 (numeric_value_out_of_range).

What the server log shows

ERROR:  value "9999999999999999999999" is out of range for type bigint

Why PostgreSQL raises this — what the manual says

Section 8.1.1 Integer Types:

“Attempts to store values outside of the allowed range will result in an error.”

bigint is a signed 64-bit integer. Converting a value beyond its range cannot be represented, so PostgreSQL reports 22003.

Common causes

How to fix it

  1. Use numeric for arbitrarily large integers.
  2. Validate inputs against the bigint range before conversion.
  3. Cast intermediate results to numeric to avoid overflow.

Related & next steps

Reference: PostgreSQL 18 Section 8.1 “Numeric Types”.