Skip site navigation (1) Skip section navigation (2)

Re: Postgresql 8.3X supports Arrays of Composite Types?

From: Robson Fidalgo <robson(dot)fidalgo(at)gmail(dot)com>
To: pgsql-docs(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql 8.3X supports Arrays of Composite Types?
Date: 2009-04-19 21:08:18
Message-ID: 41534c40904191408t7f9b4db7lb48889ecb0abf312@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-docspgsql-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)
>

In response to

pgsql-docs by date

Next:From: Tom LaneDate: 2009-04-19 23:25:32
Subject: Re: [GENERAL] Postgresql 8.3X supports Arrays of Composite Types?
Previous:From: Robson FidalgoDate: 2009-04-19 21:03:26
Subject: Postgresql 8.3X supports Arrays of Composite Types?

pgsql-general by date

Next:From: aravind chanduDate: 2009-04-19 21:49:32
Subject: Problem with pgpool-II tool
Previous:From: Robson FidalgoDate: 2009-04-19 21:03:26
Subject: Postgresql 8.3X supports Arrays of Composite Types?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group