Re: function to operate on same fields, different records? - Mailing list pgsql-general

From Eric G. Miller
Subject Re: function to operate on same fields, different records?
Date
Msg-id 20010402010419.A2756@calico.local
Whole thread Raw
In response to Re: function to operate on same fields, different records?  (will trillich <will@serensoft.com>)
List pgsql-general
On Mon, Apr 02, 2001 at 01:47:29AM -0500, will trillich wrote:
> On Sat, Mar 31, 2001 at 11:52:47AM -0800, Eric G. Miller wrote:
> > I think you still can have a function that uses field names.  But then
> > your field names *have* to be the same.  That's the only difference.
>
> i've tried
>
>     create function gpa(OPAQUE) ....
>
> and psql tells me it successfully
>
>     CREATED
>
> something, but
>
>     \df
>
> shows no such function.
>
> if i do
>
>     create function gpa(classTable) ...
>
> then it probably won't be called via
>
>     select gpa(studentTable) ...
>
> what arg to i specify to allow varying records (with a subset of
> exactly-the-same-names field subset) to be passed to a function?

The trickery only seems to work for trigger functions.

You can duplicate the function definition for each table.  PostgreSQL
will differentiate them not only by name but parameters, so they can all
be called "gpa".  I still think the five parameter function is the most
general approach...

--
Eric G. Miller <egm2@jps.net>

pgsql-general by date:

Previous
From: Marek PUBLICEWICZ
Date:
Subject: - dumping a tables' 'subtree'
Next
From: "Richard Huxton"
Date:
Subject: Re: pg_ctl stop returns error