Thread: PostgreSQL 7.3: help on new CREATE TYPE

PostgreSQL 7.3: help on new CREATE TYPE

From
"Jerome Chochon"
Date:
Hi all.
 
I have read the last version of PostgreSQL (7.3 beta) and found that the second version of CREATE TYPE is very interesting.
 
So we can create a type that look like a RECORD.
For example:
CREATE TYPE adress AS (number int, street text, country VARCHAR);
 
But can i use this type in a table definition like this:
CREATE TABLE person (his_name VARCHAR, his_adress adress);
 
Someone can answer to my question.
 
Thanks for your help.
 
Jérôme Chochon.
 
 

Re: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE

From
"Christopher Kings-Lynne"
Date:
Hi Jerome,

The RECORD type is used for writing stored procedures and functions that
return sets.

eg.  CREATE FUNCTION foo() RETURNS setof adress
AS '...';

Sort of thing...

Chris
-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Jerome Chochon
Sent: Tuesday, 17 September 2002 5:17 PM
To: pgsql-hackers@postgresql.org; pgsql-announce@postgresql.org;
pgsql-general@postgresql.org
Subject: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE


Hi all.

I have read the last version of PostgreSQL (7.3 beta) and found that the
second version of CREATE TYPE is very interesting.

So we can create a type that look like a RECORD.
For example:
CREATE TYPE adress AS (number int, street text, country VARCHAR);

But can i use this type in a table definition like this:
CREATE TABLE person (his_name VARCHAR, his_adress adress);

Someone can answer to my question.

Thanks for your help.

Jérôme Chochon.


Re: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE

From
"Jerome Chochon"
Date:
Sorry if my english is not very good. ;-).

When I say that the second form of CREATE TYPE allow you to make RECORD type
like RECORD, i don't want to speak about the record in PlPgsql but RECORD
from programming language like ADA or C (typedef struct).

So the real question is:
Can I use this new type like other user-type ?
CREATE TABLE person (his_name VARCHAR, his_adress adress);
...where adress is CREATE TYPE adress AS (number int, street text, country
VARCHAR);

Thanks for your reply ?




----- Original Message -----
From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
To: "Jerome Chochon" <jerome.chochon@ensma.fr>;
<pgsql-hackers@postgresql.org>; <pgsql-announce@postgresql.org>;
<pgsql-general@postgresql.org>
Sent: Tuesday, September 17, 2002 11:25 AM
Subject: RE: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE


> Hi Jerome,
>
> The RECORD type is used for writing stored procedures and functions that
> return sets.
>
> eg.  CREATE FUNCTION foo() RETURNS setof adress
> AS '...';
>
> Sort of thing...
>
> Chris
> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Jerome Chochon
> Sent: Tuesday, 17 September 2002 5:17 PM
> To: pgsql-hackers@postgresql.org; pgsql-announce@postgresql.org;
> pgsql-general@postgresql.org
> Subject: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE
>
>
> Hi all.
>
> I have read the last version of PostgreSQL (7.3 beta) and found that the
> second version of CREATE TYPE is very interesting.
>
> So we can create a type that look like a RECORD.
> For example:
> CREATE TYPE adress AS (number int, street text, country VARCHAR);
>
> But can i use this type in a table definition like this:
> CREATE TABLE person (his_name VARCHAR, his_adress adress);
>
> Someone can answer to my question.
>
> Thanks for your help.
>
> Jérôme Chochon.
>


Re: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE

From
Tom Lane
Date:
"Jerome Chochon" <jerome.chochon@ensma.fr> writes:
> Can I use this new type like other user-type ?
> CREATE TABLE person (his_name VARCHAR, his_adress adress);
> ...where adress is CREATE TYPE adress AS (number int, street text, country
> VARCHAR);

Not at the moment, though that might be an interesting direction to
pursue in future releases.  At present, the only thing such a type is
useful for is to define the argument or result type of a function that
takes or returns records.

            regards, tom lane

Re: [HACKERS] PostgreSQL 7.3: help on new CREATE TYPE

From
"Christopher Kings-Lynne"
Date:
> When I say that the second form of CREATE TYPE allow you to make
> RECORD type
> like RECORD, i don't want to speak about the record in PlPgsql but RECORD
> from programming language like ADA or C (typedef struct).
>
> So the real question is:
> Can I use this new type like other user-type ?
> CREATE TABLE person (his_name VARCHAR, his_adress adress);
> ...where adress is CREATE TYPE adress AS (number int, street text, country
> VARCHAR);

No.

By the way - the pgsql-announce list is not for asking quetsions in!

Chris