Re: numeric field overflow - Mailing list pgsql-general

From Scott Marlowe
Subject Re: numeric field overflow
Date
Msg-id dcc563d10910052330g1559eaf6qeb6eb8693edb9ece@mail.gmail.com
Whole thread Raw
In response to numeric field overflow  (Nurzhan Kirbassov <km.sameboy@gmail.com>)
List pgsql-general
On Tue, Oct 6, 2009 at 12:20 AM, Nurzhan Kirbassov <km.sameboy@gmail.com> wrote:
> Good day.
>
> I may be misunderstanding the NUMERIC type description in the manual,
> so can anyone please help me with this? Description says:
>
> "The scale of a numeric is the count of decimal digits in the
> fractional part, to the right of the decimal point. The precision of a
> numeric is the total count of significant digits in the whole number,
> that is, the number of digits to both sides of the decimal point. ...
> Integers can be considered to have a scale of zero. "
>
> However, I am not able to insert numbers that have number of digits
> equal to the precision and the scale equal to 0.
>
> F.E.:
>
> CREATE TABLE test.test
> (
>  rate numeric(5,1)
> )

This declares a numeric of 5 digits, with 1 to the right of the decimal point.

>
> INSERT INTO test.test VALUES (10000)
>
> Generates an error:

Like it should.  however this:

CREATE TABLE test.test ( rate numeric(5,0));
INSERT INTO test.test VALUES (10000);
INSERT 0 1

Works just fine.

pgsql-general by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: numeric field overflow
Next
From: Stuart Bishop
Date:
Subject: Re: attempted to lock invisible tuple - PG 8.4.1