Re: Dereferencing a 2-dimensional array in plpgsql - Mailing list pgsql-general

From Tom Lane
Subject Re: Dereferencing a 2-dimensional array in plpgsql
Date
Msg-id 20625.1107192011@sss.pgh.pa.us
Whole thread Raw
In response to Dereferencing a 2-dimensional array in plpgsql  (Sven Willenberger <sven@dmv.com>)
Responses Re: Dereferencing a 2-dimensional array in plpgsql
List pgsql-general
Sven Willenberger <sven@dmv.com> writes:
> I am having an issue with trying to dereference a 2-dimensional array in
> plpgsql. The idea is to have an setup like:

> DECLARE
> myarray varchar[][];
> myvar    char;
> BEGIN
> --stuff
> myarray[1] := ''{value1,value2,value3}'';
> myarray[2] := ''{valuea,valueb,valuec}'';

> --If I then:

> myvar := array[1][1];

> --I get a subscript error generated.

That isn't a two-dimensional array, it's a one-dimensional array with
some curly braces in the element values.  Keep in mind that the number
of []s you write in the DECLARE is just decoration --- it's not enforced.
What's determining the actual array shape in this example is the
subscripts you write in the assignments.

            regards, tom lane

pgsql-general by date:

Previous
From: "Mike-Olumide Johnson"
Date:
Subject: Identity Problem
Next
From: "Guy Rouillier"
Date:
Subject: Re: Postgresql and Athlon64 ?