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.
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.
Hi all,
I have a problem with inserting one milling records into a table using a
function. This is for testing. The backend crashes on that every time,
although the error messages seem to be different. Can I post a full
description here or should that go to pgsql-general?
Thanks.
Best Regards,
Michael Paesold
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
Show quoted text
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 TYPEHi 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.
"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
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
Illustra did a very nice job with "composite types" which
correspond to these record types. The composite types
were able to be used as a column type as jerome describes.
The subcolumns were accessed with dots. This gave us
schema.table.column.attribute
where of course attribute could itself be a composite type....
Well, ok, it had some drawbacks, too.
If we ever are serious about implementing this I would help
with discussing and/or writing the specs. I can put together a nice spec.
When I get a break on my book project, I might just write it up anyway.
elein
elein@norcov.com
PS: Everyone please forgive me for reading list mail late and out of order...
I am in awe of anyone keeping up.
Show quoted text
On Tuesday 17 September 2002 07:22, Tom Lane wrote:
"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
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?