I'm using PgSQL 9.1.
SELECT 5.1::text
is working fine with output '5.1'
in PgAdmin3, but with JDBC Prepared statement EXEC SQL, the result always as '5.0999999'
.
Of source SELECT to_char(5.1, '9.9')
will work, however this is not what I want. I want to get '5'
in the case of 5.0
without decimal point, so I just stay on the ::text
conversion.
My assumption is there might be some session environment settings affected to this conversion somewhere, but I can't figure out how to find.
I know this is just a silly question... please help.
I think I found a solution. Try to cast into numeric type first...
SELECT (5.1::numeric)::text
Please add your answer if you have a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With