Re: function to operate on same fields, different records?

From: "Eric G(dot) Miller" <egm2(at)jps(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: "Eric G(dot) Miller" <egm2(at)jps(dot)net>
Subject: Re: function to operate on same fields, different records?
Date: 2001-04-02 08:04:19
Message-ID: 20010402010419.A2756@calico.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)jps(dot)net>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wade Burlingame 2001-04-02 08:56:16 Why are quotes required around table / column names in SQL statements?
Previous Message Marek PUBLICEWICZ 2001-04-02 07:50:38 - dumping a tables' 'subtree'