Re: setUseServerPrepare & typecasts
От | Barry Lind |
---|---|
Тема | Re: setUseServerPrepare & typecasts |
Дата | |
Msg-id | 3DD28A9C.7040208@xythos.com обсуждение исходный текст |
Ответ на | setUseServerPrepare & typecasts (Scott Lamb <slamb@slamb.org>) |
Список | 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@postgresql.org) >
В списке pgsql-jdbc по дате отправления: