Re: Constructors in clases

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: cima <ruel(dot)cima(at)facinf(dot)uho(dot)edu(dot)cu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Constructors in clases
Date: 2005-03-08 07:24:51
Message-ID: 20050308072451.GB53394@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, Mar 08, 2005 at 12:41:17AM -0500, cima wrote:

> is the following possible in postgresql 7.4?
>
> create table t1 (name varchar(10), age int2);
>
> create table t2 (position varchar(20), worker t1);
>
> if it is then how do i insert a record in t2?

The following doesn't work in 7.4.7 but it does work in 8.0.1:

INSERT INTO t2 VALUES ('position 1', row('name 1', 50));

SELECT * FROM t2;
position | worker
------------+---------------
position 1 | ("name 1",50)
(1 row)

SELECT position, (worker).name, (worker).age FROM t2;
position | name | age
------------+--------+-----
position 1 | name 1 | 50
(1 row)

> in the documentation i've read about object relational dbs there
> is some constructor involved but i'm not sure how to work with it.

The worker column holds values of a composite type but those values
aren't relations, if that's what you're looking for.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message David 2005-03-08 14:26:57 Re: Getting started - Interfacing questions
Previous Message Afton & Ray Still 2005-03-08 07:07:11 Re: [ADMIN] PostgreSQL installation problem on Windows XP Home