Re: Arrays - Mailing list pgsql-general

From Bob Pawley
Subject Re: Arrays
Date
Msg-id 010b01c622ad$f675f510$ac1d4318@owner
Whole thread Raw
In response to Arrays  (Bob Pawley <rjpawley@shaw.ca>)
Responses Re: Arrays  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List 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@sss.pgh.pa.us>
To: "Bob Pawley" <rjpawley@shaw.ca>
Cc: "Postgresql" <pgsql-general@postgresql.org>
Sent: Thursday, January 26, 2006 11:16 AM
Subject: Re: [GENERAL] Arrays


> Bob Pawley <rjpawley@shaw.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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Arrays
Next
From: Eric E
Date:
Subject: Re: Arrays