Re: Composite Types

From: imad <immaad(at)gmail(dot)com>
To: Jose <jvfingercw(at)wiseup(dot)com(dot)br>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Composite Types
Date: 2006-11-06 19:34:12
Message-ID: 1f30b80c0611061134m769a4871rbb1523360fff00aa@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

This is *not* a good practice to handle elements of a composite data
type seperately because they all build it up together and without one
of it, the data type is meaningless.

Secondly, If you are going to base our application on this principle,
you better rethink your design.

--Imad
www.EnterpriseDB.com

On 11/1/06, Jose <jvfingercw(at)wiseup(dot)com(dot)br> wrote:
>
>
> Hello
> I am using postgres r8.1 and i make 2 Composite Types
> as:
> CREATE TYPE regiao AS
> (pais_nome varchar(150),
> estado_nome varchar(150),
> estado_sigla varchar(4),
> cidade_nome varchar(150));
> ALTER TYPE regiao OWNER TO postgres;
> ==================
> and
> CREATE TYPE telcontato AS
> (telefone1 varchar(15),
> telefone2 varchar(15),
> telefone3 varchar(15));
> ALTER TYPE telcontato OWNER TO postgres;
> ===========
> and a table as
> REATE TABLE unidades
> (
> unidade_pa int4 NOT NULL,
> unidade_tipo int4,
> unidade_nome varchar(100) NOT NULL,
> unidade_razao varchar(150),
> unidade_bandeira varchar(1),
> unidade_endereco varchar(150),
> unidade_bairro varchar(80),
> unidade_regiao regiao,
> unidade_cep varchar(10),
> unidade_cnpj varchar(110),
> unidade_radio varchar(15),
> unidade_contato telcontato,
> unidade_abertura date,
> unidade_contrato date,
> CONSTRAINT unidades_pkey PRIMARY KEY (unidade_pa)
> )
> WITHOUT OIDS;
> ALTER TABLE unidades OWNER TO postgres;
>
> I can insert without problems rows in my table and of corse I can retreave
> this information if I use select * from .....
> ok
> My problem is , How I can make a query to retreave the cidade_nome from
> table unidades
> If I use for example
> select unidade_regiao.estado_sigla from unidades
> I recive this message:
>
> ERROR: missing FROM-clause entry for table "unidade_regiao"
>
> If I try use
> select unidade_regiao.(estado_sigla) from unidades
>
> I recive this message
>
> ERROR: syntax error at or near "(" at character 23
>
>
> So I ask How I can retrive a specific information if I use a Composite Types
> ?
>
> Thaks any help
> J. V. Finger
>
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message imad 2006-11-06 19:43:58 Re: Distribution of results
Previous Message Jorge Godoy 2006-11-06 19:25:37 Re: Distribution of results