Re: numeric field overflow

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Nurzhan Kirbassov <km(dot)sameboy(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: numeric field overflow
Date: 2009-10-06 06:30:53
Message-ID: dcc563d10910052330g1559eaf6qeb6eb8693edb9ece@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 6, 2009 at 12:20 AM, Nurzhan Kirbassov <km(dot)sameboy(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2009-10-06 07:00:58 Re: Documentation on standard conforming strings?
Previous Message Stuart Bishop 2009-10-06 06:29:07 Re: attempted to lock invisible tuple - PG 8.4.1