Subject: composite objects

From: [email-masked] (Gregory Klein)
Date: Tue, 25 Jun 91 16:31:51 -0700

In the Postgres tutorial, the following composite object was defined:

create EMP(name=c12,salary=float8,age=int4,dept=c12,manager=EMP)

and attributes were appended to the object using

append to EMP (name="Sam",salary=1000,age=40,dept="shoe",
manager=mgr-lookup("shoe"))

where mgr-lookup was defined as the function by

define function mgr-lookup(c12) returns EMP as
retrieve (EMP.all) where EMP.name=DEPT.manager and DEPT.name=$1

Since Postgres 2.1 does not appear to be able to define this sort of
function, is there a way to populate composite objects?

Thanks,
Greg Klein

---

From: [email-masked] (Mike Olson)
Date: Tue, 25 Jun 91 16:46:10 PDT

here's a way to make this happen; how it works should be clear from the
example.

	create EMP (name = char16, salary = int4, mgr_name = char16)

	define postquel function manager (EMP) returns EMP is
	    retrieve (e.all) from e in EMP where e.name = current.mgr_name

the 'define postquel function' declares a method on class EMP and adds a
virtual column, 'manager', to the class.  this isn't perfect, but will
do what you want at the cost of an additional key stored in each EMP
instance.

					mike olson
					postgres research group
					uc berkeley
					[email-masked]