pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: Gabriel Furstenheim Milerud <furstenheim@gmail.com>
Cc: adrian.klaver@aklaver.com
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: Converting to number with given format
Date: Thu, 20 Sep 2018 08:23:30 +1000
Message-ID: <87y3bxdt3x.fsf@gmail.com> (raw)
In-Reply-To: <CAJN3DWqxXTkduu2itfq9yoKP9zAC5N-PXMJ4OuJJrPciCk5Wtg@mail.gmail.com>
References: <CAJN3DWrePeKge2-e6NPTkHSpXfndCu7JdKBwALUpMkjKx7dm=Q@mail.gmail.com>
	<aa556ef6-2c98-1837-9799-7e0715268ba9@aklaver.com>
	<CAJN3DWp38h+TCgivCw86ESf_Z8+OmrYPtdgsVKpx8-k3G=TqHA@mail.gmail.com>
	<a038d40a-0d4b-1df0-f3c3-29e36489aeb9@aklaver.com>
	<CAJN3DWqxXTkduu2itfq9yoKP9zAC5N-PXMJ4OuJJrPciCk5Wtg@mail.gmail.com>


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




view thread (9+ messages)  latest in thread

Message-ID: <87y3bxdt3x.fsf@gmail.com>
Permalink:  ../87y3bxdt3x.fsf@gmail.com/
Also on:    postgresql.org/message-id/87y3bxdt3x.fsf@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: theophilusx@gmail.com, furstenheim@gmail.com, adrian.klaver@aklaver.com
  Subject: Re: Converting to number with given format
  In-Reply-To: <87y3bxdt3x.fsf@gmail.com>
  References: <CAJN3DWrePeKge2-e6NPTkHSpXfndCu7JdKBwALUpMkjKx7dm=Q@mail.gmail.com> <aa556ef6-2c98-1837-9799-7e0715268ba9@aklaver.com> <CAJN3DWp38h+TCgivCw86ESf_Z8+OmrYPtdgsVKpx8-k3G=TqHA@mail.gmail.com> <a038d40a-0d4b-1df0-f3c3-29e36489aeb9@aklaver.com> <CAJN3DWqxXTkduu2itfq9yoKP9zAC5N-PXMJ4OuJJrPciCk5Wtg@mail.gmail.com> <87y3bxdt3x.fsf@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox