Re: to_char with locale decimal separator
| От | Adrian Klaver |
|---|---|
| Тема | Re: to_char with locale decimal separator |
| Дата | |
| Msg-id | 51F81384.70601@gmail.com обсуждение исходный текст |
| Ответ на | Re: to_char with locale decimal separator (Ingmar Brouns <swingi@gmail.com>) |
| Список | pgsql-general |
On 07/30/2013 08:34 AM, Ingmar Brouns wrote: > > Thanks for your time, appreciate it! As a dirty alternative, you could also do > something like: > > select translate(5.000::text,'.',substr(to_char(.0),2,1)); > > Not so nice, but would work. Though I still feel there should be a more > elegant of doing this... > Two issues. 1) Leading and trailing zeros tend to be a personal preference and what and how many, even more so. Pre-canned implementations for formatting seem to best guess. I could see where trying to cover every conceivable possibility would get complex. 2) You where looking at converting variable precision values, not uncommon, but adds a layer of complexity. For instance using the Python locale module it is possible to have it format a number according to locale and have trailing zeros, but it will pad to the specified precision(6 by default). So you still need to track something, in this case precision. You could take your quick and dirty solution and put it in a function(to_char_trailing(numeric) and hide the dirty part:) >> -- >> Adrian Klaver >> adrian.klaver@gmail.com -- Adrian Klaver adrian.klaver@gmail.com
В списке pgsql-general по дате отправления: