Prepared statement parameters for an 'IN ()' clause

From: "Jason L(dot) Buberel" <jason(at)buberel(dot)org>
To: PostgreSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Prepared statement parameters for an 'IN ()' clause
Date: 2007-10-17 14:37:15
Message-ID: 47161E1B.9000508@buberel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 );

For the prepared statement, I have tried:

prepare st1(text, text, text, text[] );

Then invoked it as:

execute st1('CA', 'SUNNYVALE', '94086',
'{2007-10-01,2007-09-25,2007-09-15}' );

But the use of the text array as input parameter does not seem to be
correctly used in the 'IN' clause. My query consistently returns no results.

Any quick syntax fix for this?

Thanks
Jason

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-10-17 14:52:14 Re: What encoding to use for English, French, Spanish
Previous Message Kevin Grittner 2007-10-17 13:57:04 Re: [HACKERS] CVS and Eclipse