Re: Arrays

From: Bob Pawley <rjpawley(at)shaw(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Arrays
Date: 2006-01-26 19:23:18
Message-ID: 010b01c622ad$f675f510$ac1d4318@owner
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Because it gives me an error otherwise.

I am following the rules layed out in the documentation as follows -

Bob

----

8.10.2. Array Value Input
Now we can show some INSERT statements.

INSERT INTO sal_emp
VALUES ('Bill',
'{10000, 10000, 10000, 10000}',
'{{"meeting", "lunch"}, {"meeting"}}');
ERROR: multidimensional arrays must have array expressions with matching
dimensionsNote that multidimensional arrays must have matching extents for
each dimension. A mismatch causes an error report.

INSERT INTO sal_emp
VALUES ('Bill',
'{10000, 10000, 10000, 10000}',
'{{"meeting", "lunch"}, {"training", "presentation"}}');

INSERT INTO sal_emp
VALUES ('Carol',
'{20000, 25000, 25000, 25000}',
'{{"breakfast", "consulting"}, {"meeting", "lunch"}}');
A limitation of the present array implementation is that individual elements
of an array cannot be SQL null values. The entire array can be set to null,
but you can't have an array with some elements null and some not. (This is
likely to change in the future.)

The result of the previous two inserts looks like this:

SELECT * FROM sal_emp;
name | pay_by_quarter | schedule
-------+---------------------------+-------------------------------------------
Bill | {10000,10000,10000,10000} |
{{meeting,lunch},{training,presentation}}
Carol | {20000,25000,25000,25000} |
{{breakfast,consulting},{meeting,lunch}}
(2 rows)

----- Original Message -----
From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bob Pawley" <rjpawley(at)shaw(dot)ca>
Cc: "Postgresql" <pgsql-general(at)postgresql(dot)org>
Sent: Thursday, January 26, 2006 11:16 AM
Subject: Re: [GENERAL] Arrays

> Bob Pawley <rjpawley(at)shaw(dot)ca> writes:
>> insert into specifications values ('1', '{25, 50, 100, gpm}', '{{100,
>> 250, 500, DegF}}',
>> '{{{10, 40, 100, psi}}}', '{{{{60, 120, 150, psi}}}}' );
>
> Why are you putting in all those extra braces?
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq

In response to

Responses

  • Re: Arrays at 2006-01-26 19:43:36 from Stephan Szabo

Browse pgsql-general by date

  From Date Subject
Next Message Eric E 2006-01-26 19:25:08 Re: Arrays
Previous Message Tom Lane 2006-01-26 19:16:54 Re: Arrays