X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 95FFB329D55 for ; Wed, 15 Sep 2004 13:38:49 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07214-06 for ; Wed, 15 Sep 2004 12:38:43 +0000 (GMT) Received: from curry.tmsl.demon.co.uk (tmsl-adsl.demon.co.uk [80.177.114.181]) by svr1.postgresql.org (Postfix) with ESMTP id 166B7329D4D for ; Wed, 15 Sep 2004 13:38:44 +0100 (BST) Received: from bacon.tmsl.demon.co.uk (bacon.tmsl.demon.co.uk [192.168.7.102]) by curry.tmsl.demon.co.uk (8.11.6/8.11.6) with ESMTP id i8FCcg013622; Wed, 15 Sep 2004 13:38:42 +0100 Date: Wed, 15 Sep 2004 13:38:40 +0100 From: Paul Thomas To: Tim Penhey Cc: "pgsql-jdbc @ postgresql . org" Subject: Re: Calling functions with numeric parameters Message-ID: <20040915133840.A11339@bacon> References: <41482F1C.4060503@penhey.net> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 In-Reply-To: <41482F1C.4060503@penhey.net>; from tim@penhey.net on Wed, Sep 15, 2004 at 13:01:32 +0100 X-Mailer: Balsa 1.2.3 Lines: 32 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/70 X-Sequence-Number: 10960 On 15/09/2004 13:01 Tim Penhey wrote: > Hi All, > > I have a plpgsql function that takes a numeric parameter. It is for a > price in a table. The table has the price declared as numeric(10,2), and > the function parameter is just numeric. However in Java I have the price > represented as a double. > > Using jdbc setDouble for a parameter for the function causes causes an > ERROR saying that the function taking a double precision parameter does > not exist (which is obviously correct). > > What do other people do? > > Is there a way to pass a numeric parameter through JDBC? > Should the parameter to the function be a double which is the "cast" > into the numeric inside the function? > > Your ideas are welcome. I've not tried it myself but BigDecimal seems to the one to use. HTH -- Paul Thomas +------------------------------+-------------------------------------------+ | Thomas Micro Systems Limited | Software Solutions for Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +------------------------------+-------------------------------------------+