Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCaxv-00037H-7y for pgsql-general@arkaria.postgresql.org; Thu, 09 Nov 2017 00:45:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eCaxu-0007a1-Ow for pgsql-general@arkaria.postgresql.org; Thu, 09 Nov 2017 00:45:06 +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 1eCaxt-0007Yh-Ih for pgsql-general@postgresql.org; Thu, 09 Nov 2017 00:45:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eCaxr-0005hh-1r for pgsql-general@postgresql.org; Thu, 09 Nov 2017 00:45:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vA90j1Xr004498; Wed, 8 Nov 2017 19:45:01 -0500 From: Tom Lane To: "Igal @ Lucee.org" cc: pgsql-general Subject: Re: Migrating money column from MS SQL Server to Postgres In-reply-to: <8acca674-ac7c-2b48-9a3e-8b8acf8b2c36@lucee.org> References: <8acca674-ac7c-2b48-9a3e-8b8acf8b2c36@lucee.org> Comments: In-reply-to "Igal @ Lucee.org" message dated "Wed, 08 Nov 2017 16:32:56 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <4496.1510188301.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Nov 2017 19:45:01 -0500 Message-ID: <4497.1510188301@sss.pgh.pa.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 "Igal @ Lucee.org" writes: > I have a column named "discount" of type money in SQL Server.=C2=A0 I cre= ated=20 > the table in Postgres with the same name and type, since Postgres has a=20 > type named money, and am transferring the data by using PDI (Pentaho=20 > Data Integration) Kettle/Spoon. > Kettle throws an error though:=C2=A0 column "discount" is of type money b= ut=20 > expression is of type double precision. > The value in the offending insert is:=C2=A0 0.0 > Why does Postgres decide that 0.0 is "double precision" (which is a=20 > 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. regression=3D# create table m (m1 money); CREATE TABLE regression=3D# insert into m values (0.0); INSERT 0 1 regression=3D# insert into m values (0.0::numeric); INSERT 0 1 regression=3D# insert into m values (0.0::float8); ERROR: column "m1" is of type money but expression is of type double preci= sion LINE 1: insert into m values (0.0::float8); ^ HINT: You will need to rewrite or cast the expression. You'll need to look at the client-side code to see where it's going wrong. > The only solution I found is to set the column in Postgres to DOUBLE=20 > PRECISION instead of MONEY, but I'm not sure if there are negative side=20 > effects to that? Well, it's imprecise. Most people don't like that when it comes to monetary amounts. regards, tom lane --=20 Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general