Re: Converting to number with given format

Поиск
Список
Период
Сортировка
От Tim Cross
Тема Re: Converting to number with given format
Дата
Msg-id 87y3bxdt3x.fsf@gmail.com
обсуждение исходный текст
Ответ на Re: Converting to number with given format  (Gabriel Furstenheim Milerud <furstenheim@gmail.com>)
Список pgsql-general
Gabriel Furstenheim Milerud <furstenheim@gmail.com> writes:

> Sorry,
> So basically what I'm trying to achieve is the following. There is an input
> file from the user and a configuration describing what is being inserted.
> For example, he might have Last activity which is 'YYYY-MM-DD HH:mi:ss' and
> Join date which is only 'YYYY-MM-DD' because there is no associated timing.
> For dates this works perfectly and it is possible to configure what the
> input from the user will be. Think it is as a dropdown where the user says,
> this is the kind of data that I have.
>
> Maybe that is not possible with numbers? To say in a format something like
> "my numbers have comma as decimal separator and no thousands separators" or
> "my numbers are point separated and have comma as thousands separator"
>
> Nice thing of having a string for the format is that I can use it as a
> parameter for a prepared statement.
>

I think this is normally something much better dealt with at the client
level. Things like comma separator/grouping in numbers is really just a
'human' thing and is very locale dependent. The values 9,999 and 9999
are the same values. Things can quickly become complicated as you can
have locale information at both the server and client end and they may
not be the same. 

As you should always be sanitising your data before inserting into the
database anyway, you may as well just add this as another check at the
client end.

Tim

-- 
Tim Cross


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

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: how to know whether query data from memory after pg_prewarm
Следующее
От: Dylan Luong
Дата:
Сообщение: help with startup slave after pg_rewind