Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Jdbc > Re: PreparedSta...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 1897 of 2010
Post > Topic >>

Re: PreparedStatement cache and dynamic queries

by tgl@[EMAIL PROTECTED] (Tom Lane) Mar 1, 2008 at 01:33 PM

Dave Cramer <pg@[EMAIL PROTECTED]
> writes:
> On 1-Mar-08, at 11:00 AM, Ken Johanson wrote:
>> 4) They want parameter escaping but in the context of lists:
>> WHERE foo IN ('a','b','c',...dynamic list).
>> Is this possible in a database neutral way?
>> 
>> String[] ar = new String[]{"a","b"};
>> "WHERE foo IN ?",
>> ps.setObject(1,ar,Types.ARRAY);
>> 
>> (I've never tried this snippet but presume it won't work due to the  
>> zero-len case which should failfast according to sql, I believe)
>> 
> As far as I know this won't work

Since about 8.2 the backend has been able to cater to this type of thing
using "scalar = ANY(array)" syntax: that does sup****t pu****ng the whole
array through as one parameter and it doesn't fail for the zero-elements
case.  It won't work with IN though; AFAICT the code snippet shown above
is a flat violation of the SQL spec.  (The ANY(array) business isn't in
the SQL spec either, but since the spec doesn't assign a meaning to ANY
except with a subquery as argument, we felt we could get away with this
extension.)

Since this behavior is nowhere to be found in the spec, imagining that
you can have it in a "database neutral way" is sheer fantasy.  Any DB
that can do it at all will have made their own choices about how to
shoehorn it into SQL syntax.

			regards, tom lane

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




 3 Posts in Topic:
PreparedStatement cache and dynamic queries
pg-user@[EMAIL PROTECTED]  2008-03-01 09:00:32 
Re: PreparedStatement cache and dynamic queries
pg@[EMAIL PROTECTED] (Da  2008-03-01 12:49:28 
Re: PreparedStatement cache and dynamic queries
tgl@[EMAIL PROTECTED] (T  2008-03-01 13:33:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 8:18:11 CDT 2008.