Postgresql 8.3X supports Arrays of Composite Types?

From: Robson Fidalgo <rdnf(at)cin(dot)ufpe(dot)br>
To: pgsql-docs(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Postgresql 8.3X supports Arrays of Composite Types?
Date: 2009-04-19 21:03:26
Message-ID: 41534c40904191403m2eeabc27tc4bc6ce206c87464@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-general

Hello,
I am using postgresql 8.3X and I created a table (see example below) that
has an attribute that is an Array of a Composite Type (ROW). However, I do
not know how can I insert a record in this table.

Well, I've searched the mailing lists and have found little said about the
OR features. In postgres 8.3X on-line documentation (
http://www.postgresql.org/docs/8.3/static/arrays.html) I found "Arrays of
any built-in or user-defined base type, enum type, or composite type can be
created", however there is no example that explains how can I do an insert
into an attribute that is an Array of Composite Type. Considering the
example below, "persons have N phones" I create (with success) the Person
table with an array of phones, but I have not success with Insert values.
There is some one that can help me?

Thanks in advances,

Robson

Example:

CREATE table phone (
cod varchar,
num varchar);

CREATE TABLE person (
name varchar,
telephone phone[]);

Until here is everything ok, but I have not success with insert values, then
I tried:

1)insert into person values ('Joe', '{("1","1111"),("2","2222") }');
2)insert into person values ('Joe', array[('1','1111'),('2','2222')]);
3)insert into person values ('Joe', array[row('1','1111'),row('2','2222')]);
4)insert into person values ('Joe',
_phone[phone('1','1111'),phone('2','2222')]);**
** considering _phone = name of array type (automatically created by
postgres) and phone = name of composite type (also automatically created by
postgres)

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Robson Fidalgo 2009-04-19 21:08:18 Re: Postgresql 8.3X supports Arrays of Composite Types?
Previous Message Bruce Momjian 2009-04-15 22:42:54 Re: Inheritance mention

Browse pgsql-general by date

  From Date Subject
Next Message Robson Fidalgo 2009-04-19 21:08:18 Re: Postgresql 8.3X supports Arrays of Composite Types?
Previous Message Martijn van Oosterhout 2009-04-19 20:43:49 DISTINCT ON without ORDER BY