Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 5894F9FBCD1 for ; Tue, 5 Jun 2007 12:33:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 98196-03 for ; Tue, 5 Jun 2007 12:33:01 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from oxford.xeocode.com (unknown [62.232.55.118]) by postgresql.org (Postfix) with ESMTP id 156D49FB33F for ; Tue, 5 Jun 2007 12:33:01 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1Hvb1f-0005lG-2c; Tue, 05 Jun 2007 16:32:51 +0100 From: Gregory Stark To: "ben sagal" Cc: "Andreas Joseph Krogh" , Subject: Re: Array paramiters In-Reply-To: (ben sagal's message of "Tue, 5 Jun 2007 17:46:48 +0300") Organization: EnterpriseDB References: <200706050938.58019.andreak@officenet.no> <200706051632.31349.andreak@officenet.no> X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.jdbc" 126) Date: Tue, 05 Jun 2007 16:32:50 +0100 Message-ID: <87abvect7h.fsf@oxford.xeocode.com> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/16 X-Sequence-Number: 17078 "ben sagal" 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