Functional dysfunction

From: ERIC Lawson - x52010 <eric(at)bioeng(dot)washington(dot)edu>
To: pg-novice list <pgsql-novice(at)postgresql(dot)org>
Subject: Functional dysfunction
Date: 2000-07-28 19:09:09
Message-ID: Pine.GSO.4.10.10007281157050.10919-100000@gandalf.bioeng.washington.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm trying to create a function to return a set of tuples showing the
contents of an attribute (last name, ln) from a relation (adr) if the
contents of any of another set of attributes (nsrrelat01-4) match a text
string given as the argument of the function. The SQL statements shown
here,

create function matRelat(text)
returns setof ADR as
'select ln from ADR where
nsrrelat01 ~* \'$1\'::text or
nsrrelat02 ~* \'$1\'::text or
nsrrelat03 ~* \'$1\'::text or
nsrrelat04 ~* \'$1\'::text;'
language 'sql';

generate this error message:

ERROR: function declared to return type adr does not retrieve (adr.*)

Can anybody here tell me either 1) how to write the function so it works,
or 2) a simple way of using SQL commands to achieve the desired result,
i.e., I don't want to use

select ln from ADR where nsrrelat01 ~* '[text to match]' or
nsrrelat02 ~* '[text to match]' or nsrrelat03 ~*
'[text to match]' or nsrrelat04 ~* '[text to match]';

I've tried to iterate over attributes using wild card notation, e.g.,

select ln from ADR where * ~* '[text to match]';

but of course that doesn't work; however, perhaps I'm overlooking some
simple mechanism to use SQL to achieve my aim.

If you can help, TIA.

best,
Eric

James Eric Lawson
Research Publications Editor III
National Simulation Resource

eric(at)bioeng(dot)washington(dot)edu

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Everyday language is a part of the human organism and is no less
complicated than it. - Ludwig Wittgenstein (1889-1951) [Tractatus
Logico-Philosophicus, 1921]

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2000-07-28 21:03:07 Re: Functional dysfunction
Previous Message Ross J. Reedstrom 2000-07-28 17:06:55 Re: Re: 4 billion record limit?