Re: numeric cast oddity

From: Thom Brown <thombrown(at)gmail(dot)com>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org, Sandy Oz <alexandra(at)compulab(dot)co(dot)il>
Subject: Re: numeric cast oddity
Date: 2009-12-03 10:14:38
Message-ID: bddc86150912030214x615da0e0oc021abaf4f203a28@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2009/12/3 Sim Zacks <sim(at)compulab(dot)co(dot)il>

> When I cast an integer to numeric using :: notation it ignores the scale
> and precision that I specify, but when I use the cast function it uses
> the scale and precision that I specify.
>
> Sim
>
> select version();
> "PostgreSQL 8.3.5 on i586-pc-linux-gnu, compiled by GCC
> i586-pc-linux-gnu-gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.0.1)"
>
> select -1::numeric(20,4)
> ?column?
> numeric
> ------------
> -1.0000
>
> select cast(-1 as numeric(20,4))
> numeric
> numeric(20,4)
> -------------------
> -1.0000
>
>
I've just spotted what you mean. Ignore my previous response.

Thom

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Avi Rozen 2009-12-03 10:35:29 Re: [Bacula-users] Catastrophic changes to PostgreSQL 8.4
Previous Message Thom Brown 2009-12-03 10:07:14 Re: numeric cast oddity