Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1E51A632821; Sun, 19 Apr 2009 18:08:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 37824-09; Sun, 19 Apr 2009 18:08:16 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f220.google.com (mail-gx0-f220.google.com [209.85.217.220]) by mail.postgresql.org (Postfix) with ESMTP id A22106326CF; Sun, 19 Apr 2009 18:08:20 -0300 (ADT) Received: by gxk20 with SMTP id 20so4295953gxk.19 for ; Sun, 19 Apr 2009 14:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=t6sROOcZ4poJwcpT53cnLa7rpmPwGNX+u0NceWWvtvg=; b=QsnOCU13g3BZ1DtJAS9Laugw3ax4aCkgkbFXAA9sQ4BMVwlCBaLgIpUI64XaWcIgl9 9P+CFNRGkV+D/DCTQnlIaaAHv4am65sUfW90Rxne6uE4lNKFiDeIz5U54MIVAQjfocgQ Ej/ih+6YUD+XfqcR++o63oRVuL54DN9MEnVoI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=eKoKuc0MktEXwpSrjnvQJBHuKi3KUEAD3L1MhNJ5xBwt3PxcJN9xe7xGVGamejgPTF +30fmqAYNtht67FAgYB3sOV1+8cAVFWKqlGf4vVnM77+EQalwhHgHwQKdxSAgLHyODmF UhY7V13aXCaPA/KInedpcx+2sde3poqH6pBwE= MIME-Version: 1.0 Received: by 10.231.18.4 with SMTP id u4mr3137398iba.33.1240175298855; Sun, 19 Apr 2009 14:08:18 -0700 (PDT) In-Reply-To: <41534c40904191403m2eeabc27tc4bc6ce206c87464@mail.gmail.com> References: <41534c40904191403m2eeabc27tc4bc6ce206c87464@mail.gmail.com> Date: Sun, 19 Apr 2009 18:08:18 -0300 Message-ID: <41534c40904191408t7f9b4db7lb48889ecb0abf312@mail.gmail.com> Subject: Re: Postgresql 8.3X supports Arrays of Composite Types? From: Robson Fidalgo To: pgsql-docs@postgresql.org, pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary=002215046b4725c4a10467eed0f3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200904/38 X-Sequence-Number: 5126 --002215046b4725c4a10467eed0f3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit > > 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) > --002215046b4725c4a10467eed0f3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

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). Ho= wever, 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 abo= ut the OR features. In postgres 8.3X on-line documentation (http:/= /www.postgresql.org/docs/8.3/static/arrays.html) I found "Arrays o= f 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 t= he example below, "persons have N phones" I create (with success)= the Person table with an array of phones, but I have not success with Inse= rt values. There is some one that can help me?

Thanks in advances,

Robson

Example:

CREATE table phone (
=A0 cod varchar,
=A0 num varchar);

CREATE TABLE person (
=A0 name varchar,
=A0 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","1= 111"),("2","2222") }');
2)insert into perso= n values ('Joe', array[('1','1111'),('2',&#= 39;2222')]);
3)insert into person values ('Joe', array[row('1','1111= '),row('2','2222')]);
4)insert into person values (&= #39;Joe', _phone[phone('1','1111'),phone('2',&#= 39;2222')]);**
** considering _phone =3D name of array type (automatically created by post= gres) and phone =3D name of composite type (also automatically created by p= ostgres)


--002215046b4725c4a10467eed0f3--