Search Postgresql Archives

Re: Dereferencing a 2-dimensional array in plpgsql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sven Willenberger <sven@xxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux