Locale number formatting

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
desrocchi
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 28.11.2006, 13:51

Locale number formatting

Post by desrocchi »

Hi everyone,
I'm having problems with the function to_char in a query on postgresql 8.1.5 and Delphi 7 Pro.

There's this function in my query:

"trim(to_char(impo, '9G999G999G990D99'))"

this should return a number with locale (Italian) settings and works fine if I try this at designtime, but when I use it at runtime it puts a wrong thousand separator (a ",") while the decimal separator is right (always a ",").

ex:
Designtime trim(to_char(5432.66, '9G999G999G990D99'))
returns "5.432,66"

Runtime trim(to_char(5432.66, '9G999G999G990D99'))
returns "5,432,66"

I tried resetting the properties DecimalSeparator and ThousandSeparator right before opening the query but nothing changes.

Any clue?

Thanks,
Daniele
desrocchi
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 28.11.2006, 13:51

Post by desrocchi »

I forgot: I also updated Zeos to the last release 6.6.0 beta.

Daniele
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

Try adding a ZSQLMonitor to your application and logging your queries. It may be that zeos adds something before your query runs.

Regards,

Ben
desrocchi
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 28.11.2006, 13:51

Post by desrocchi »

Hi,
I tried what you suggested but I can see no errors in the log:

2006-11-28 15.24.59 cat: Execute, proto: postgresql-8, msg: SELECT trim(to_char(impo, '9G999G999G990D99')) AS impox, * FROM q_rate

is there something I'm not doing right?

bye,
Daniele
desrocchi
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 28.11.2006, 13:51

Post by desrocchi »

I couldn't solve the problem so I took a different approach to obtain what I need:

I created a view that contains all the required fields plus the to_char function, this way when I query "SELECT * FROM view_table" the number is formatted the way I expect it to be.

bye,
Daniele
Post Reply