pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Schaber <schabi@logix-tt.com>
To: sramsay@uga.edu
Cc: pgsql-sql@postgresql.org
Subject: Re: functions in WHERE clause
Date: Mon, 27 Mar 2006 15:32:51 +0200
Message-ID: <4427E983.8050601@logix-tt.com> (raw)
In-Reply-To: <20060305151652.GA14216@cantor.english.uga.edu>
References: <20060305151652.GA14216@cantor.english.uga.edu>

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



view thread (11+ messages)

Message-ID: <4427E983.8050601@logix-tt.com>
Permalink:  ../4427E983.8050601@logix-tt.com/
Also on:    postgresql.org/message-id/4427E983.8050601@logix-tt.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: schabi@logix-tt.com, sramsay@uga.edu
  Subject: Re: functions in WHERE clause
  In-Reply-To: <4427E983.8050601@logix-tt.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