From: Gregory Stark <stark@enterprisedb.com>
To: ben sagal <bsagal@gmail.com>
Cc: Andreas Joseph Krogh <andreak@officenet.no>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Array paramiters
Date: Tue, 05 Jun 2007 16:32:50 +0100
Message-ID: <87abvect7h.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <b72a6e130706050746m37c191e7j3d5ceababe467566@mail.gmail.com>
References: <b72a6e130706040629j4b44ee6g60c15d61b146fc5@mail.gmail.com>
<200706050938.58019.andreak@officenet.no>
<b72a6e130706050723p4c91920ftfeef04417543b104@mail.gmail.com>
<200706051632.31349.andreak@officenet.no>
<b72a6e130706050746m37c191e7j3d5ceababe467566@mail.gmail.com>
"ben sagal" <bsagal@gmail.com> writes:
> I would ideally like to use a prepared statement, in which i can on each
> execution insert a different array? the method u suggest will not allow use
> of a prepared statement.
The alternative is building up a string form of an array of your list of
parameters and passing it as a single parameter.
Something like
$sth = $dbh->prepare("select * from foo where bar =ANY(?::int[])")
$sth->execute('{' . join(@array, ',') . '}');
This works better with something like integers for which you don't have to
worry about escaping. The method the other poster suggested would be lower
overhead I think but this only gives you one prepared query if you have a wide
variety of lengths of lists.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: stark@enterprisedb.com, bsagal@gmail.com, andreak@officenet.no
Subject: Re: Array paramiters
In-Reply-To: <87abvect7h.fsf@oxford.xeocode.com>
References: <b72a6e130706040629j4b44ee6g60c15d61b146fc5@mail.gmail.com> <200706050938.58019.andreak@officenet.no> <b72a6e130706050723p4c91920ftfeef04417543b104@mail.gmail.com> <200706051632.31349.andreak@officenet.no> <b72a6e130706050746m37c191e7j3d5ceababe467566@mail.gmail.com> <87abvect7h.fsf@oxford.xeocode.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox