Skip site navigation (1) Skip section navigation (2)

Re: Function valid only for one table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martin Knipper <knipper(at)mk-os(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Function valid only for one table
Date: 2004-05-19 17:33:19
Message-ID: 18520.1084987999@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
Martin Knipper <knipper(at)mk-os(dot)de> writes:
> I thought about a mixture of object orientation and a normal table
> for a relational database.
> someFunction() is a method for the object/table someTable.

Perhaps you could do what you want with functions accepting table
rowtypes.

	create function someFunction(someTable) returns ...

	select someFunction(t.*) from someTable t where ...
	-- works

	select someFunction(t.*) from anotherTable t where ...
	-- fails

	create function someFunction(anotherTable) returns ...

	select someFunction(t.*) from someTable t where ...
	-- still works

	select someFunction(t.*) from anotherTable t where ...
	-- now calls the second someFunction()

As of existing releases this doesn't scale well to large tables, because
passing a whole table row to a function leaks memory intraquery.  That
is fixed for 7.5 though.

			regards, tom lane

In response to

Responses

pgsql-sql by date

Next:From: Martin KnipperDate: 2004-05-19 17:41:21
Subject: Re: Function valid only for one table
Previous:From: Kornelije RabuzinDate: 2004-05-19 17:31:49
Subject: Re: Replace function ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group