numeric cast oddity

From: Sim Zacks <sim(at)compulab(dot)co(dot)il>
To: pgsql-general(at)postgresql(dot)org
Cc: Sandy Oz <alexandra(at)compulab(dot)co(dot)il>
Subject: numeric cast oddity
Date: 2009-12-03 09:13:32
Message-ID: 4B17813C.3040505@compulab.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2009-12-03 09:14:09 Re: How to auto-increment?
Previous Message Craig Ringer 2009-12-03 08:33:57 Re: Catastrophic changes to PostgreSQL 8.4