Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 1BF4A632821; Sun, 19 Apr 2009 18:03:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 26090-09; Sun, 19 Apr 2009 18:03:27 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.30]) by mail.postgresql.org (Postfix) with ESMTP id 780126326CF; Sun, 19 Apr 2009 18:03:27 -0300 (ADT) Received: by yx-out-2324.google.com with SMTP id 8so648231yxg.73 for ; Sun, 19 Apr 2009 14:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=feMAmFeoVZo/CSK3JS/c3h0yR+Khlr5GFkVYGMsNM5Q=; b=LQlHBCaokx6X6nbO+dPai+4ALz9Ktk14ThjbTicU8kkS3WNvR7L/ktIvvs9Q/FYVWH Spjrwl3RwPXJdEAcAyQFX1GteDlTAsw5McljaDNiPiX2eJmCOUh4GvAhH4IU48UwnQHp oDWL3VmTsndU+ua+wGOg205CS/vodjBkQQt+g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=t+SvqtoLT8ePs4c1WqMulnH8XgJ0F+EoVjywoDcDfGT54+6DezLMagY89DhEvWPf4A RVliY6du3tIkDWEswuvXWVYDBImWMzaul8v9qnLSwTdGtqy1J1oc4TMasQI9tAO3VIvu OzcLklqQH5SFEj73RoLA+eCUkvYjo3vdCQ74k= MIME-Version: 1.0 Received: by 10.231.30.198 with SMTP id v6mr3144303ibc.22.1240175006332; Sun, 19 Apr 2009 14:03:26 -0700 (PDT) Date: Sun, 19 Apr 2009 18:03:26 -0300 X-Google-Sender-Auth: 77a79e4c1c5048d5 Message-ID: <41534c40904191403m2eeabc27tc4bc6ce206c87464@mail.gmail.com> Subject: 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=000325579e82b639330467eebe12 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/762 X-Sequence-Number: 146718 --000325579e82b639330467eebe12 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) --000325579e82b639330467eebe12 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.or= g/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 at= tribute 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 i= s 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)

--000325579e82b639330467eebe12--