Subject | Re: [firebird-support] server-side number formatting |
---|---|
Author | Pavel Menshchikov |
Post date | 2005-07-12T11:30:39Z |
Hello sugi,
s> Anyway, it is working fine, but there's this little formatting issue
s> that i haven't been able to solve. We're using VIEWs to present the data
s> to the users, so there are tons of views with the following definition :
s> ...
s> create table my_view (
s> ....
s> amount
s> ) as select ...,
s> case (IS_PERCENT) when 1 then (AMOUNT || '%') else ('$' || AMOUNT) end
s> from my_table
s> ...
s> This works to a certain degree, so for example,
s> AMOUNT = 10, IS_PERCENT = 1 ---> will be displayed as '10%'
s> AMOUNT = 12345, IS_PERCENT = 0 ---> will be displayed as '$12345.0000'
As you've been told already, try to avoid server-side formatting. But
in this case you could try to cast the amount:
create table my_view (
....
amount
) as select ...,
case (IS_PERCENT) when 1 then (AMOUNT || '%')
else ('$' || cast(AMOUNT as numeric(18,2))) end
from my_table
...
--
HTH
Best regards,
Pavel Menshchikov
http://www.ls-software.com
s> Anyway, it is working fine, but there's this little formatting issue
s> that i haven't been able to solve. We're using VIEWs to present the data
s> to the users, so there are tons of views with the following definition :
s> ...
s> create table my_view (
s> ....
s> amount
s> ) as select ...,
s> case (IS_PERCENT) when 1 then (AMOUNT || '%') else ('$' || AMOUNT) end
s> from my_table
s> ...
s> This works to a certain degree, so for example,
s> AMOUNT = 10, IS_PERCENT = 1 ---> will be displayed as '10%'
s> AMOUNT = 12345, IS_PERCENT = 0 ---> will be displayed as '$12345.0000'
As you've been told already, try to avoid server-side formatting. But
in this case you could try to cast the amount:
create table my_view (
....
amount
) as select ...,
case (IS_PERCENT) when 1 then (AMOUNT || '%')
else ('$' || cast(AMOUNT as numeric(18,2))) end
from my_table
...
--
HTH
Best regards,
Pavel Menshchikov
http://www.ls-software.com