ERROR: numeric field overflow

PostgreSQL Numeric field overflow

Numeric field overflow

Create table

CREATE TABLE test(
  id numeric(4,2) NOT NULL,
  description character varying(250),
  reg_date timestamp without time zone
);

Wrong action

insert into test(id, description, reg_date) 
values (123, 'test_dsp', now());

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

Correct function

insert into test(id, description, reg_date) 
values (1, 'test_dsp', now());

insert into test(id, description, reg_date) 
values (12, 'test_dsp', now());

Query returned successfully: one row affected, 43 ms execution time.