From: | Scott Lamb <slamb(at)slamb(dot)org> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | setUseServerPrepare & typecasts |
Date: | 2002-11-13 10:03:02 |
Message-ID: | 3DD22356.2060208@slamb.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
I've got a bunch of queries that deal with functions in the custom
functions I've made. So I might have a function foo(integer) returning
text. A simple case:
ps = conn.prepare("select foo(?)");
and then calling
ps.setObject(1, new Integer(42), Types.INTEGER);
Without setUseServerPrepare, this works fine. With setUseServerPrepare,
this complains that foo(text) does not exist and suggests explicit
typecasts. With
select foo(?::integer)
it works again.
Should this be necessary? I am telling it the type of that parameter
before I execute the statement. Does it need to know that at prepare
time? Is the explicit cast in the SQL the only way to do that?
I am using a layer of my own design that creates the placeholders and
binds the parameters for me from named, typed parameters. So I could
easily have it automatically insert "{fn convert(?, <TYPENAME>)}"
instead of "?" into the SQL everywhere I use parameters. Would that be
the best way to fix this problem?
Thanks,
Scott
From | Date | Subject | |
---|---|---|---|
Next Message | snpe | 2002-11-13 16:20:25 | Re: streaming result sets: progress |
Previous Message | Thomas O'Dowd | 2002-11-13 03:56:52 | Re: res.wasNull() troubles when using CASE? |