From: | Barry Lind <blind(at)xythos(dot)com> |
---|---|
To: | Scott Lamb <slamb(at)slamb(dot)org> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: setUseServerPrepare & typecasts |
Date: | 2002-11-13 17:23:40 |
Message-ID: | 3DD28A9C.7040208@xythos.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Scott,
If you use ps.setInt(1,42) does it work? I want to isolate the problem.
In just looking at the code, it seems that the setInt() and
setObject() methods do the same thing.
And I know that the setInt() methods should work since the regression
test uses them.
thanks,
--Barry
Scott Lamb wrote:
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
From | Date | Subject | |
---|---|---|---|
Next Message | Lachlan Deck | 2002-11-13 17:29:15 | Help with JDBC connection... |
Previous Message | nferrier | 2002-11-13 16:35:24 | Re: streaming result sets: progress |