views:

29

answers:

0

I want to format long numbers using thousend separator. It can be done using to_char function just like:

SELECT TO_CHAR(76543210.98, '999G999G990D00')

But when my PostgreSQL server with UTF-8 encoding is on Polish version of Windows such SELECT ends with:

ERROR:  invalid byte sequence for encoding "UTF8": 0xa0
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

In to_char pattern G is described as: group separator (uses locale). This SELECT works without error when server is running on Linux with Polish locale.

As a workaround I use space instead of G in format string, but I think there should be way to set thousend separator just like in Oracle:

ALTER SESSION SET NLS_NUMERIC_CHARACTERS=', ';

Is such setting available for PostgreSQL?