From: | Alessandro Aste <alessandro(dot)aste(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | convert real to numeric. |
Date: | 2018-10-18 10:28:29 |
Message-ID: | CAM9F+O2m9nV7F95P3g5ymmxTTvdiB-s2F1KJqVZTKjE0ZvW2uw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
Postresql version: 10.5
I need to convert an SQL field from real to numeric, but I’m getting a
strange behavior.
See the following query in preprod:
select amount, amount::numeric, amount::numeric(16,4),
amount::varchar::numeric from mytable where id = 32560545;
Result:
17637.75, 17637.8, 17637.8000, 17637.75
As you can see, the conversion to ::numeric is truncating the number to
just 1 decimal digit.
Also we tried to change the schema definition of this table, from real to
numeric, and the value was truncated.
Is the ::varchar::numeric workaround a good option in your opinion? Any
other ideas to fix this issue?
Thank you,
From | Date | Subject | |
---|---|---|---|
Next Message | Raghavendra Rao J S V | 2018-10-18 12:25:31 | pg_dump backup utility is taking more time around 24hrs to take the backup of 28GB |
Previous Message | Laurenz Albe | 2018-10-18 08:14:17 | Re: postgres server process crashes when using odbc_fdw |