cast numeric with scale and precision to numeric plain

Поиск
Список
Период
Сортировка
Искать
От
Sim Zacks
Тема
cast numeric with scale and precision to numeric plain
Дата
Msg-id
4ADC8DCC.4080609@compulab.co.il
Список
Дерево обсуждения
cast numeric with scale and precision to numeric plain Sim Zacks <sim@compulab.co.il>
Re: cast numeric with scale and precision to numeric plain Scott Bailey <artacus@comcast.net>
Re: cast numeric with scale and precision to numeric plain Tom Lane <tgl@sss.pgh.pa.us>
Re: cast numeric with scale and precision to numeric plain Sim Zacks <sim@compulab.co.il>
Re: cast numeric with scale and precision to numeric plain Adrian Klaver <aklaver@comcast.net>
Re: cast numeric with scale and precision to numeric plain Tom Lane <tgl@sss.pgh.pa.us>
Re: cast numeric with scale and precision to numeric plain Sim Zacks <sim@compulab.co.il>
Re: cast numeric with scale and precision to numeric plain Adrian Klaver <aklaver@comcast.net>
Re: cast numeric with scale and precision to numeric plain Scott Marlowe <scott.marlowe@gmail.com>
I'm using 8.2.4


Numeric with scale precision always shows the trailing zeros.

Numeric plain only shows numbers after the decimal point that are being
used.


I would like to have the data in my table with scale and precision, but
my views to be cast to numeric without any scale or precision.

However, when I cast a numeric(16,4) to a ::numeric it doesn't cast it.


In order to get the results I want, I have to cast it twice ::double
precision::numeric and then it removes the trailing zeros.


Is there any way to cast directly from numeric with scale and precision
to plain numeric?


example:


create table test(f1 numeric(16,4));

insert into test(f1)values(15),(200.004),(12.4123);
select f1 from test;
15.0000
200.0040
12.4123


select f1::numeric from test
15.0000
200.0040
12.4123


select f1::float::numeric from test
15
200.004
12.4123


В списке pgsql-general по дате отправления
От: Brad Nicholson
Дата:
От: Tom Lane
Дата:
FAQ