From: | sramsay(at)uga(dot)edu |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | functions in WHERE clause |
Date: | 2006-03-05 15:16:52 |
Message-ID: | 20060305151652.GA14216@cantor.english.uga.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi All,
I've got one of these:
SELECT * from some_table WHERE
test_for_equality_is_syntactically_ugly;
What I'd like to do is encapsulate the WHERE clause in a function,
but I'm having no end of trouble.
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.
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.
Perhaps I'm barking up the wrong tree here. It seems like what I
really need is a way to have some kind of rewrite rule (e.g. when
you see "foo(x)" substitute ugly string). Sort of like a Lisp macro
;)
Steve
--
Stephen Ramsay
Assistant Professor
Department of English
University of Georgia
email: sramsay(at)uga(dot)edu
web: http://cantor.english.uga.edu/
PGP Public Key ID: 0xA38D7B11
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2006-03-05 17:26:35 | Re: functions in WHERE clause |
Previous Message | Michael Glaesemann | 2006-03-05 11:50:28 | Re: Check/unique constraint question |