X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7AD059DCCB0 for ; Mon, 27 Mar 2006 09:32:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60310-02 for ; Mon, 27 Mar 2006 09:32:44 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 5D8079DCCFF for ; Mon, 27 Mar 2006 09:32:37 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (T938b.t.pppool.de [89.55.147.139]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 2B0D6656CD; Mon, 27 Mar 2006 15:33:20 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 7D53F184ED71E; Mon, 27 Mar 2006 15:32:51 +0200 (CEST) Message-ID: <4427E983.8050601@logix-tt.com> Date: Mon, 27 Mar 2006 15:32:51 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: sramsay@uga.edu Cc: pgsql-sql@postgresql.org Subject: Re: functions in WHERE clause References: <20060305151652.GA14216@cantor.english.uga.edu> In-Reply-To: <20060305151652.GA14216@cantor.english.uga.edu> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] X-Spam-Score: 0.105 X-Spam-Level: X-Archive-Number: 200603/413 X-Sequence-Number: 24759 Hi, Steve, sramsay@uga.edu wrote: > SELECT * from some_table WHERE > test_for_equality_is_syntactically_ugly; > The WHERE clause expects the function to return a boolean value. I > can certainly return a boolean value from a function, but here it > seems to me that what the function really has to do is return a > set of boolean values -- the test in the WHERE clause sometimes > evaluates to true and sometimes evaluates to false, and that is in > turn used to constrain the query results. But you can't return a > set of anything (I don't think) in a WHERE clause, because it seems > to want a singular boolean value. And this is as it is intended. The equality test is applied row-by-row, and for each row, it is either true or false, but not undecided. So your query should look like SELECT * FROM some_table WHERE your_function(column_a, column_b); > Is it possible to do what I'm trying to do? I've written a few > simple sql and pl/pgsql functions over the years, but I'm no expert. Yes, it is. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org