pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Igal @ Lucee.org <igal@lucee.org>
To: Postgres General Postgres General <pgsql-general@postgresql.org>
Subject: Re: Migrating money column from MS SQL Server to Postgres
Date: Wed, 8 Nov 2017 17:11:33 -0800
Message-ID: <4b6a0bfb-0cbc-b407-feaa-0be86f06e4d9@lucee.org> (raw)
In-Reply-To: <CAF3N6oS3REmTvwimqhRm0oikyncTUoiQ23sHKYrXJENxcW7JvA@mail.gmail.com>
References: <8acca674-ac7c-2b48-9a3e-8b8acf8b2c36@lucee.org>
	<4497.1510188301@sss.pgh.pa.us>
	<CAF3N6oS3REmTvwimqhRm0oikyncTUoiQ23sHKYrXJENxcW7JvA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

Thank you all for your help:

On 11/8/2017 4:45 PM, Tom Lane wrote:
> "Igal @ Lucee.org" <igal@lucee.org> writes:
>> The value in the offending insert is:  0.0
>>
>> Why does Postgres decide that 0.0 is "double precision" (which is a
>> weird name in my opinion -- why can't it just be double) and not money?
> Kettle must be telling it that --- on its own, PG would think '0.0'
> is numeric, which it does have a cast to money for.

Looks like you are correct.  Kettle shows me the INSERT statement and 
when I execute it outside of Kettle (in a regular SQL client), the 
INSERT succeeds.

On 11/8/2017 4:45 PM, David G. Johnston wrote:

> The lack of quotes surrounding the value is significant.  Money input 
> requires a string literal.  Only (more or less) integer and double 
> literal values can be written without the single quotes.

That didn't work.  I CAST'ed the value in the SELECT to VARCHAR(16) but 
all it did was change the error message to say that it expected `money` 
but received `character varying`.

On 11/8/2017 4:52 PM, Allan Kamau wrote:

>  On Nov 9, 2017 03:46, "Tom Lane" <tgl@sss.pgh.pa.us wrote:
>>      Well, it's imprecise.  Most people don't like that when it comes to
>>      monetary amounts.
>
>  Could try using NUMERIC datatype for such a field. 

That worked.  I have set the column type to NUMERIC(10, 2) and it seemed 
to have worked fine.  I am not dealing with large amounts here, so 10 
digits is plenty.

This is a "staging" phase where I first import the data into Postgres 
and then I will move it into the permanent tables in the next phase, so 
even taking it as VARHCAR would have been OK.  I just worried about 
using FLOAT/DOUBLE, and Tom confirmed that that was the wrong way to go.

Thanks again,

Igal Sapir
Lucee Core Developer
Lucee.org <http://lucee.org/;

view thread (12+ messages)  latest in thread

Message-ID: <4b6a0bfb-0cbc-b407-feaa-0be86f06e4d9@lucee.org>
Permalink:  ../4b6a0bfb-0cbc-b407-feaa-0be86f06e4d9@lucee.org/
Also on:    postgresql.org/message-id/4b6a0bfb-0cbc-b407-feaa-0be86f06e4d9@lucee.org

 · 

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: igal@lucee.org
  Subject: Re: Migrating money column from MS SQL Server to Postgres
  In-Reply-To: <4b6a0bfb-0cbc-b407-feaa-0be86f06e4d9@lucee.org>
  References: <8acca674-ac7c-2b48-9a3e-8b8acf8b2c36@lucee.org> <4497.1510188301@sss.pgh.pa.us> <CAF3N6oS3REmTvwimqhRm0oikyncTUoiQ23sHKYrXJENxcW7JvA@mail.gmail.com> <4b6a0bfb-0cbc-b407-feaa-0be86f06e4d9@lucee.org>

* 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