pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stan Raby <sraby@computerpark.co.uk>
To: pgsql-admin@postgreSQL.org
Subject: How do I insert data into a table within a table
Date: Tue, 28 Nov 2000 16:19:04 +0000
Message-ID: <00112816263400.11277@Cpark34> (raw)


--
As I understand it when you create a table in postgres that it is automatically
a type. Therefore you can then the declare an attribute of this type in another
table e.g

create table person
( 
  first_name  char(20),
  second_name char(20) 
);

create table couple
( 
  man   person,
  woman person
);
 
The couple table can be queried without any problems e.g. 

select * from couple;

returns :

man|woman
---+-----
(0 rows)

select couple.man.first_name, couple.man.second_name from couple;

returns :

first_name|second_name
----------+-----------
(0 rows)

But how do you put data into the couple table ?
I have tried a number of methods but without any success.

e.g.
insert into
couple(couple.man.first_name,couple.man.second_name,couple.woman.first_name,couple.woman.second_name)
values('Fred','Smith','Jane','White');   

insert into 
couple(man(first_name,second_name),woman(first_name,second_name))
values('Fred','Smith','Jane','White');

insert into 
couple.man.first_name,couple.man.second_name,couple.woman.first_name,couple.woman.second_name
values('Fred','Smith','Jane','White');

insert into
couple(man.first_name,man.second_name,woman.first_name,woman.second_name)
values('Fred','Smith','Jane','White');

All of these (plus others) all produce parser errors.
e.g. ERROR :  parser: parse error at or near "."

Thankyou in advance for any help.

------------------------------------
Stan Raby
Computer Park Limited
Tel: +44 1536 417155
Fax: +44 1536 417566
email: sraby@computerpark.co.uk



Message-ID: <00112816263400.11277@Cpark34>
Permalink:  ../00112816263400.11277@Cpark34/
Also on:    postgresql.org/message-id/00112816263400.11277@Cpark34

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sraby@computerpark.co.uk
  Subject: Re: How do I insert data into a table within a table
  In-Reply-To: <00112816263400.11277@Cpark34>
  References: <00112816263400.11277@Cpark34>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox