Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCbQE-0004pF-V6 for pgsql-general@arkaria.postgresql.org; Thu, 09 Nov 2017 01:14:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eCbQD-0000cw-PS for pgsql-general@arkaria.postgresql.org; Thu, 09 Nov 2017 01:14:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eCbNi-0004c7-80 for pgsql-general@postgresql.org; Thu, 09 Nov 2017 01:11:46 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1eCbNa-0006Kf-EC for pgsql-general@postgresql.org; Thu, 09 Nov 2017 01:11:44 +0000 Received: by mail-pf0-x22f.google.com with SMTP id a8so3064090pfc.0 for ; Wed, 08 Nov 2017 17:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lucee-org.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=w9ivEUaEdHDY76/8eWocLbhw0jBs1jOaV2fLBzA0doE=; b=rAmYGLPXtna20W5p7uAZfE1pSMb1GSSc7qIAceC24Vh3uU6AR4ewEbI8VzmxFSYpu0 xVqwF8gm94ubBOaNS/vbBgAP/xl8qYcKy/5Dygh+rmsrUP7sVGllZgdGD5t9lYt2t5Sv qHG2LbgpjtOHEaoOcXdurimYK35/DmvIbXkAuXOaB2074UJ0h4VqeZG44xbGVkSjeAGO w/YC7tpEO54+aG+OwEfLb2cU13vHdrx4L8IL2iC250h3MY+mftgfTfs4kUxIYaTlhJwk eVjXLDxGxlb5iYwHa/0azYfnfCqVTNwChjiYxC4MGxeHUbJ9RbKzj2xYgx7O5SgXtpEb CunQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=w9ivEUaEdHDY76/8eWocLbhw0jBs1jOaV2fLBzA0doE=; b=pKQMx6M1Krc4rg0g/0HwF2XoS7RbyARXmZfxGSqijBrcVOFWgjoenKj8KsWhhxPPEY IonFzEVsIm4bKBAXneT2xn+w8mUELyzeZmnUoNtl6k+Wj/nil55VlEfub2Xcb/GANy6D 8QXYDQ386IXa6XsnG726qabiU1QoLo/P1cNGfuZLEdsxyL4Q15wi0l9ef7iwtAPgDcaa SsJGhED+6V4Rk3XrWLHDq5rssjLhRFulKQigTAOBHRiQ0Y+siHH+EnjXKQsDYDFhxWhi YDuqv3AhjUdz2j1OYVEdo620Dplzez0A7apCSoT5hY+fdNQ3YTIwa1Re14ZiCeOzA7b2 FiNg== X-Gm-Message-State: AJaThX7DxNRyPqbM+Urbq2yaC9wM1DOmeVaA6RAuG173aPk8pZw1f7Qg eBXJaYHDAfUQxcRDCP0PTIkLWU0c X-Google-Smtp-Source: ABhQp+T0e94QF6NvawVPHV1kDGkaLxN/V5+Z19OF8f6yfuWjlmCaaF77v4/hxkrZ2skeHQbGBKJAwg== X-Received: by 10.98.156.15 with SMTP id f15mr2352606pfe.35.1510189896867; Wed, 08 Nov 2017 17:11:36 -0800 (PST) Received: from [192.168.1.15] (45-19-167-161.lightspeed.irvnca.sbcglobal.net. [45.19.167.161]) by smtp.googlemail.com with ESMTPSA id m74sm10756713pfi.2.2017.11.08.17.11.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 17:11:36 -0800 (PST) Subject: Re: Migrating money column from MS SQL Server to Postgres To: Postgres General Postgres General References: <8acca674-ac7c-2b48-9a3e-8b8acf8b2c36@lucee.org> <4497.1510188301@sss.pgh.pa.us> From: "Igal @ Lucee.org" Message-ID: <4b6a0bfb-0cbc-b407-feaa-0be86f06e4d9@lucee.org> Date: Wed, 8 Nov 2017 17:11:33 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------9C3A7149673F38A9348562B0" Content-Language: en-US List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org This is a multi-part message in MIME format. --------------9C3A7149673F38A9348562B0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Thank you all for your help: On 11/8/2017 4:45 PM, Tom Lane wrote: > "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" >      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 --------------9C3A7149673F38A9348562B0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit 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

--------------9C3A7149673F38A9348562B0--