Re: Populating a sparse array piecemeal in plpgsql

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

Thank you for your reply, but I don't really understand how to use this
information.
My problem is that I can put one value into this array, and that's it.
Any subsequent attempts to put another value elsewhere in the array are
rebuffed, saying that the subscripts are out of range. I don't
understand what I would do "by hand" that would help this.

Topher Eliot
christopher(dot)eliot(at)nagrastar(dot)com
[]

> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Thursday, May 15, 2008 12:30 AM
> To: Eliot, Christopher
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Populating a sparse array piecemeal in plpgsql
>
> "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 ludwig 2008-05-15 14:43:11 Re: Password safe web application with postgre*s*
Previous Message Fernando 2008-05-15 14:04:52 Re: Password safe web application with postgre