Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling functions with numeric parameters

0 views
Skip to first unread message

Tim Penhey

unread,
Sep 15, 2004, 8:01:32 AM9/15/04
to
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.
Tim


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majo...@postgresql.org)

Dave Cramer

unread,
Sep 15, 2004, 8:36:09 AM9/15/04
to
Tim,

Use setBigDecimal

Dave

--
Dave Cramer
519 939 0336
ICQ # 14675561
www.postgresintl.com


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Paul Thomas

unread,
Sep 15, 2004, 8:38:40 AM9/15/04
to

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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Tim Penhey

unread,
Sep 15, 2004, 8:49:30 AM9/15/04
to
Dave Cramer wrote:

>Tim,
>
>Use setBigDecimal
>
>Dave
>
>
Thanks. Missed that one.
Tim

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

0 new messages