Re: ERROR: array subscript out of range - Mailing list pgsql-general

From Tom Lane
Subject Re: ERROR: array subscript out of range
Date
Msg-id 261.1239394724@sss.pgh.pa.us
Whole thread Raw
In response to ERROR: array subscript out of range  (chinchu2005 <chinchu2005@gmail.com>)
List pgsql-general
chinchu2005 <chinchu2005@gmail.com> writes:
> declare
> i integer;
> j integer;
> a integer[][];
> begin
> for i in 1..10 loop
> for j in 1..2 loop
> a[i][j]:=i*j;

This isn't going to work --- it implies dynamically resizing the array,
and plpgsql isn't smart enough to do that for a multidimensional array.
Do you actually need a 2-D array here?  If so you'll have to initialize
it to the right dimensions to start with, eg with
    a := '{{1,2,3,4,5,6,7,8,9,10},{1,2,3,4,5,6,7,8,9,10}}';

            regards, tom lane

pgsql-general by date:

Previous
From: chinchu2005
Date:
Subject: ERROR: array subscript out of range
Next
From: Pedro Doria Meunier
Date:
Subject: Re: Internationalization