Search Postgresql Archives

convert real to numeric.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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,


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux