22003: numeric_value_out_of_range
PostgreSQLWhat does it mean?
A numeric value is outside the range allowed by the target type. For example, writing a value larger than 2 billion into an integer column, or a number too large for a numeric(5,2) column.
Why does it happen?
Exceeding smallint/integer/bigint limits; exceeding numeric(p,s) precision/scale; arithmetic overflow; a sum/product exceeding the type's capacity; a sequence reaching the upper bound of its type.
How to fix it
Change the column/parameter to a wider type (bigint instead of integer, increase numeric precision): ALTER TABLE my_table ALTER COLUMN my_column TYPE bigint; Round (ROUND) or validate the value according to the business rule. If an intermediate calculation overflows, compute the expression as numeric. For sequence overflow, widen the type.