Type conversion

Поиск
Список
Период
Сортировка
Искать

Type conversion

От:
Ice Planet <ice@adiemus.sk>
Дата:
Hello

I have one big select that computes some value. The value is in format numeric (40,4). Then is this value send to console and 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 and i must 
use explicit typecast, but i dont know how! I have look in manual, but there are informations about float8 only and at the bottom 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

От:
Thomas Lockhart <lockhart@alumni.caltech.edu>
Дата:
> 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

FAQ