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

From: will trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: function to operate on same fields, different records?
Date: 2001-04-02 19:02:51
Message-ID: 20010402140251.B10727@serensoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Apr 02, 2001 at 10:21:34AM -0400, Tom Lane wrote:
> will trillich <will(at)serensoft(dot)com> writes:
> > i've tried
> > create function gpa(OPAQUE) ....
> > and psql tells me it successfully
> > CREATED
> > something, but
> > \df
> > shows no such function.
>
> I believe \df suppresses opaque-argument functions, on the theory that
> they're probably just I/O functions. But OPAQUE won't do you any good
> anyway unless you code the function in C.
>
> > 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?
>
> Inheritance seems to work for this in current sources:
>
> regression=# create table p1 (f1 int);
> CREATE
> regression=# create table p2 (f2 int) inherits (p1);
> CREATE
> regression=# create function getf1(p1) returns int as '
> regression'# select $1.f1' language 'sql';
> CREATE
> regression=# insert into p1 values(1);
> INSERT 1030276 1
> regression=# insert into p2 values(11,22);
> INSERT 1030277 1
> regression=# select getf1(p1) from p1;
> getf1
> -------
> 1
> 11
> (2 rows)

ding! light comes on ... never thought of that. mucho cool, mucho
thanks! lots of new exploring to delve into now...

--
does a brain cell think?

will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin L 2001-04-02 19:10:45 problem with subselect: NOT IN
Previous Message Poul L. Christiansen 2001-04-02 18:56:48 Re: What could be the reason for EXTREMELY slow INSERTs?