Thread: Type conversion

Type conversion

From
Ice Planet
Date:
Hello

I have one big select that computes some value. The value is in format numeric (40,4). Then is this value send to
consoleand when someone on console agree with the number then is the number send to database where i need to do 
 
something like this

select TheNumberFromConsole/(select max(division_point) from table1)

Division_point is in format numeric (40,4). But the number is sometimes small and sometimes big, when the number is
big,then is all OK, but when the number is small i got error message that / for float8 (!) and numeric is not possible
andi must 
 
use explicit typecast, but i dont know how! I have look in manual, but there are informations about float8 only and at
thebottom is written that most of functions for float8 works for numeric so i try:
 

select numeric (TheNumberFromConsole)/(select max(division_point) from table1)

But this don't work too...

Please help how should i written the statement correct.

Thanks for help and sorry for my bad english.
                      Best regards                                             Ice Planet

e-mail: ice@adiemus.sk
ICQ#: 67765483




Re: Type conversion

From
Thomas Lockhart
Date:
> select TheNumberFromConsole/(select max(division_point) from table1)

Try
 select '1234.5678'/(select max(division_point) from table1);

The quotes around the apparent floating point number keeps Postgres from
assuming that it *is* a floating point number, and it later decides that
it must have been a numeric() type.
                       - Thomas