Re: Prepared statement parameters for an 'IN ()' clause - Mailing list pgsql-general

From Sam Mason
Subject Re: Prepared statement parameters for an 'IN ()' clause
Date
Msg-id 20071017152513.GI10098@samason.me.uk
Whole thread Raw
In response to Prepared statement parameters for an 'IN ()' clause  ("Jason L. Buberel" <jason@buberel.org>)
List pgsql-general
On Wed, Oct 17, 2007 at 07:37:15AM -0700, Jason L. Buberel wrote:
> Can someone point me to an example of creating a prepared statement for a
> query with an 'IN' clause?
>
> The query looks like this:
>
> select value from table where
> state = $1 and city = $2 and zip = $3 and
> date in ( $4 );

You're asking here whether "date" matches a single item named by
parameter "4".

> Any quick syntax fix for this?

Try:

  date = ANY ($4);

"ANY" treats its parameter as an array, so will accept an array as a
parameter.  I've not tried this on a large dataset, so I'm not sure what
sort of performance characteristics you should expect.


  Sam

pgsql-general by date:

Previous
From: Josh Trutwin
Date:
Subject: Array intersection
Next
From: "Albe Laurenz"
Date:
Subject: Re: Prepared statement parameters for an 'IN ()' clause