Re: Calling functions with numeric parameters

From: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
To: Tim Penhey <tim(at)penhey(dot)net>
Cc: "pgsql-jdbc (at) postgresql (dot) org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Calling functions with numeric parameters
Date: 2004-09-15 12:38:40
Message-ID: 20040915133840.A11339@bacon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


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 |
+------------------------------+-------------------------------------------+

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tim Penhey 2004-09-15 12:49:30 Re: Calling functions with numeric parameters
Previous Message Dave Cramer 2004-09-15 12:36:09 Re: Calling functions with numeric parameters