Re: Converting to number with given format - Mailing list pgsql-general

From Tim Cross
Subject Re: Converting to number with given format
Date
Msg-id 87y3bxdt3x.fsf@gmail.com
Whole thread Raw
In response to Re: Converting to number with given format  (Gabriel Furstenheim Milerud <furstenheim@gmail.com>)
List 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 by date:

Previous
From: Thomas Munro
Date:
Subject: Re: how to know whether query data from memory after pg_prewarm
Next
From: Dylan Luong
Date:
Subject: help with startup slave after pg_rewind