Unix Technical Forum

Arrays of records?

This is a discussion on Arrays of records? within the Pgsql General forums, part of the PostgreSQL category; --> Hi all; I was wondering how one would define an array of complex data types or records. Any ideas ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 06:17 PM
Chris Travers
 
Posts: n/a
Default Arrays of records?

Hi all;

I was wondering how one would define an array of complex data types or
records. Any ideas or is this simply not supported?

Best Wishes,
Chris Travers

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 06:17 PM
Pavel Stehule
 
Posts: n/a
Default Re: Arrays of records?

Hello

you can test it. PostgreSQL 8.3 supports it.

postgres=# CREATE TYPE at AS (a integer, b integer);
CREATE TYPE
postgres=# CREATE TABLE foo(a at[]);
CREATE TABLE
postgres=# INSERT INTO foo VALUES(ARRAY[(10,20)::at]);
INSERT 0 1
postgres=# INSERT INTO foo VALUES(ARRAY[(10,20)::at, (20,30)::at]);
INSERT 0 1
postgres=# SELECT * FROM foo;
a
-----------------------
{"(10,20)"}
{"(10,20)","(20,30)"}
(2 rows)

postgres=# SELECT a[1] FROM foo;
a
---------
(10,20)
(10,20)
(2 rows)

postgres=# SELECT a[1].a FROM foo;
a
----
10
10
(2 rows)

regards

Pavel Stehule




2007/7/7, Chris Travers <chris@travelamericas.com>:
> Hi all;
>
> I was wondering how one would define an array of complex data types or
> records. Any ideas or is this simply not supported?
>
> Best Wishes,
> Chris Travers
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com