Re: to_char with locale decimal separator

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: to_char with locale decimal separator
Дата
Msg-id 51F7D0E0.2050909@gmail.com
обсуждение исходный текст
Ответ на Re: to_char with locale decimal separator  (Ingmar Brouns <swingi@gmail.com>)
Ответы Re: to_char with locale decimal separator  (Ingmar Brouns <swingi@gmail.com>)
Список pgsql-general
On 07/30/2013 03:03 AM, Ingmar Brouns wrote:
> On Mon, Jul 29, 2013 at 3:12 PM, Ingmar Brouns <swingi@gmail.com> wrote:

>>
>
> anyone? Giving a locale corresponding textual representation
> of a numerical value keeping the exact nr of decimal digits
> must be a fairly common use case. Would it be an idea to
> implement a to_char function that does not take a formatting
> pattern and has this behaviour?
>

Best I can do is a proof of concept in plpythonu for determining locale
decimal point:

test=# SHOW lc_numeric ;
  lc_numeric
-------------
  en_US.UTF-8
(1 row)

test=# DO $$
     import locale
     rs = plpy.execute("SHOW lc_numeric")
     lc_n = rs[0]["lc_numeric"]
     locale.setlocale(locale.LC_NUMERIC, lc_n)
     d = locale.nl_langinfo(locale.RADIXCHAR)
     plpy.notice("Decimal point is " + d)
$$ LANGUAGE plpythonu;
NOTICE:  Decimal point is .
CONTEXT:  PL/Python anonymous code block
DO


test=# set lc_numeric = 'nl_NL.utf8';
SET
test=# DO $$
     import locale
     rs = plpy.execute("SHOW lc_numeric")
     lc_n = rs[0]["lc_numeric"]
     locale.setlocale(locale.LC_NUMERIC, lc_n)
     d = locale.nl_langinfo(locale.RADIXCHAR)
     plpy.notice("Decimal point is " + d)
$$ LANGUAGE plpythonu;
NOTICE:  Decimal point is ,
CONTEXT:  PL/Python anonymous code block
DO


>>
>>>
>>> I would like to have '1,500' as the output, what is the best way
>>> to achieve this?
>>>
>>> Thanks in advance,
>>>
>>> Ingmar
>
>


--
Adrian Klaver
adrian.klaver@gmail.com


В списке pgsql-general по дате отправления:

Предыдущее
От: Massimo Costantini
Дата:
Сообщение: Re: Fwd: Trigger on VIEW not firing
Следующее
От: Leonardo M. Ramé
Дата:
Сообщение: Alter table never finishes