Re: ANY subquery and PreparedStatements - Mailing list pgsql-jdbc

From Felipe Schnack
Subject Re: ANY subquery and PreparedStatements
Date
Msg-id 1045659407.25061.25.camel@desenv1.ritterdosreis.br
Whole thread Raw
In response to Re: ANY subquery and PreparedStatements  (Pavel Fokin <pavel@openvillage.info>)
Responses Re: ANY subquery and PreparedStatements  ("Jason S. Friedman" <jason@powerpull.net>)
List pgsql-jdbc
  Yes, this would work... but it's not very pretty :-)
  JDBC's preparedstatements should have *some way* to handle that...
simply makeing impossible to use such an useful keyword is quite bad...
  Or jdbc doesnt have it?

On Wed, 2003-02-19 at 09:49, Pavel Fokin wrote:
> Felipe Schnack wrote:
>
> >  I'm afraid it kind of impossible to use PreparedStatements with the
> >"ANY" subquery keyword... For example, if I take this query and prepare
> >it:
> >  "select * from <table> where <field> any (?)"
> >  How can I set my parameter as a list of values, so my query searches
> >for for different values of the specified field?
> >
> >
> >
> Hello,
>
> You can use a helper variable to store all your values as a string, and
> then pass it
> to prepared statement, it works for me with IN( ) and I think will work
> as well for ANY
>
> example code:
>
>         String categories = "";
>         for( int i = 0; i < someCategoryIDs.length; i++ ) {
>             if( i > 0 ) { categories = categories + ","; }
>             categories = categories + " " + someCategoryIDs[i];
>         }
>
> pstmt = connection.prepareStatement( SELECT * FROM catalog WHERE cat_id
> IN (" + categories + ") "
>
> Hope it helps
>
> Best Regards,
> Pavel Fokin,
>
> Software Engineer,
> www.openvillage.info
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
--

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Centro Universitário Ritter dos Reis
http://www.ritterdosreis.br
ritter@ritterdosreis.br
Fone/Fax.: (51)32303341


pgsql-jdbc by date:

Previous
From: Pavel Fokin
Date:
Subject: Re: ANY subquery and PreparedStatements
Next
From: awc
Date:
Subject: Re: ANY subquery and PreparedStatements