X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2CC869FA61D for ; Fri, 9 Jun 2006 04:31:11 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 95819-01 for ; Fri, 9 Jun 2006 04:31:01 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id 612C59FA5D2 for ; Fri, 9 Jun 2006 04:31:01 -0300 (ADT) Received: (qmail 18049 invoked by uid 500); 9 Jun 2006 07:33:56 -0000 Date: Fri, 9 Jun 2006 02:33:56 -0500 From: Bruno Wolff III To: CG Cc: pgsql-sql@postgresql.org Subject: Re: empty set Message-ID: <20060609073356.GA522@wolff.to> Mail-Followup-To: Bruno Wolff III , CG , pgsql-sql@postgresql.org References: <20060608214012.96518.qmail@web37907.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060608214012.96518.qmail@web37907.mail.mud.yahoo.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/107 X-Sequence-Number: 25343 On Thu, Jun 08, 2006 at 14:40:12 -0700, CG wrote: > PostgreSQL 8.1 > > I've been trying to write a SQL prepare routine. One of the challenging > elements I'm running into is an empty set ... > > "select foo from bar where foo in ? ;" > > What if "?" is an set with zero elements? What is the proper value to use to > replace "?" indicating an empty set? Something like the following suggests you can put a subquery there that returns 0 rows. I don't think that wil work for prepared queries though; so it may not help you. bruno=> select * from test where test in (select 1 where false); test ------ (0 rows)