Re: Populating a sparse array piecemeal in plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Eliot, Christopher" <christopher(dot)eliot(at)nagrastar(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Populating a sparse array piecemeal in plpgsql
Date: 2008-05-15 06:30:10
Message-ID: 27950.1210833010@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Eliot, Christopher" <christopher(dot)eliot(at)nagrastar(dot)com> writes:
> CREATE FUNCTION func1()
> RETURNS VOID AS $$
> DECLARE
> a INTEGER[2][2][2][200];
> BEGIN
> a[1][2][1][33] = 0;
> a[2][1][1][33] = 0;
> END;
> $$ LANGUAGE PLPGSQL;

> When I run this function, I get:
> ERROR: array subscript out of range.

Yeah. I'm afraid that declaration is basically just noise: it doesn't
do anything for you that "DECLARE a integer[];" wouldn't do. If you
want the array actually filled out to the indicated dimensions then
you have to do that by hand.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message mailtolouis2020-postgres 2008-05-15 07:51:56 Re: postgres crash when select a record
Previous Message Alban Hertroys 2008-05-15 06:29:48 Re: multicolumn index join