pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] Expr Abbreviations/Functions?
Date: Mon, 26 Jul 1999 13:27:58 +0300
Message-ID: <l03130302b3c1e5bcad24@[147.233.159.109]> (raw)
In-Reply-To: <199907260452.VAA30904@uno.tksoft.com>
References: <l03130302b3c0b7a3e162@[147.233.159.109]>

At 07:52 +0300 on 26/07/1999, tjk@tksoft.com wrote:


> If I recall the original question correctly, the
> "only" real solution would seem to be to define
> a function to search the appropriate fields.

Yes. The original question had a conceptual problem. It wanted to
abbreviate the expression without the name of the table. This was
nonsensical - you can't ask whether id > 3. You can ask whether person.id >
3. Just "id" could be anything in the world. Asking a database to do that
is like asking a person to play a flute in vacuum.

Another problem was that it implied returning a set of rows. This is not
well supported by postgres - and that's a known limitation.

The best thing that can be done at the moment is to have a function that
accepts the strings as parameters and returns a boolean:

CREATE FUNCTION match_three ( text, text, text, text ) RETURNS bool AS '
  SELECT (( $1 ~ $4 ) OR ( $2 ~ $4 ) OR ($3 ~ $4))
' LANGUAGE 'sql';

Then it can be used as:

SELECT * FROM table1
WHERE match_three( x1, x2, x3, 'foo' );

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (5+ messages)

Message-ID: <l03130302b3c1e5bcad24@[147.233.159.109]>
Permalink:  ../l03130302b3c1e5bcad24@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130302b3c1e5bcad24@[147.233.159.109]

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il
  Subject: Re: [SQL] Expr Abbreviations/Functions?
  In-Reply-To: <l03130302b3c1e5bcad24@[147.233.159.109]>
  References: <l03130302b3c0b7a3e162@[147.233.159.109]> <l03130302b3c1e5bcad24@[147.233.159.109]>

* 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