Subject: Defining a type

From: [email-masked] (Ed Redman)
Date: Thu, 17 Mar 1994 07:53:31 -0600

I am relatively new to Postgres. I am trying to define a type. I
have a class of Address . I want to create a class person(.....,
person_address = Address). I have tried to create two functions call
Get_Address and Put_Address . Then define type Address(...) but I seem to
get nowhere. Could someone lead me on the right path.

my address class is defined as follows

create Address(Address_id=char[10],
                Address1 = char[25],
                Address2 = char[25],
                Address3 = char[25],
                Pcode = char[7])

This is what I tried to do

define function Add_Address (language = "postquel", returntype = ?(not sure))
        arg is (Address) as "append Address (Address_id = $1,
        Address1 = $2, Address2 = $3, Address3 = $4, Pcode = $5)"

define function Get_Address (language = "postquel" Returntype = Address)
arg is (char) as "retrieve (Address.all) where Address.Address_id = $1"

define type Address( externallength = 92, input=Add_Address, Output =
Get_Address)

Thanks in advance 
Ed Redman
Computer Systems
Dalhousie Dentistry

---

From: [email-masked] (Paul M. Aoki)
Date: Wed, 23 Mar 94 17:35:23 -0800

> get nowhere. Could someone lead me on the right path.

"define type" is meant to define a new base type, meaning something
with a C definition and input/output functions written in C.

when you create a new table, a new composite (tuple) type with that 
name is created automatically.  once you define table EMP, you can
immediately define postquel functions that operate on type EMP.
(montage has a cleaner model here in that several tables can be of 
the same composite type.)

the only ways to get attributes of composite types are:
	- use a function as a virtual column
	- use the sets interface
these are documented, at least in the current release.
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki