Re: Dereferencing a 2-dimensional array in plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sven Willenberger <sven(at)dmv(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Dereferencing a 2-dimensional array in plpgsql
Date: 2005-01-31 17:20:11
Message-ID: 20625.1107192011@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sven Willenberger <sven(at)dmv(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2005-01-31 17:20:56 Re: pg_dump in 7.2.4 with trigger functions
Previous Message Joshua D. Drake 2005-01-31 17:19:14 Re: Postgresql and Athlon64 ?