Re: Populating a sparse array piecemeal in plpgsql (REDUX) - Mailing list pgsql-general

From Webb Sprague
Subject Re: Populating a sparse array piecemeal in plpgsql (REDUX)
Date
Msg-id b11ea23c0805262111i575e4eeei4f1f5e8da6566566@mail.gmail.com
Whole thread Raw
Responses Re: Populating a sparse array piecemeal in plpgsql (REDUX)  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List pgsql-general
I am trying to return a 2-d array with filled in values, but I can't
find a way to initialize the array programmatically (ie, in a
function, with the array size being determined by parameter values.

here is one approach

> Well, the point is that you need to initialize the array as a whole to
> have the dimensions you want; PG won't guess about this.  For instance
> you could do something like
>
>        declare a integer[];
>        begin
>          a := '{{null,null,null},{null,null,null},{null,null,null}}';

 I would  like the following to get  a 3 x 3 array:

declare a integer[][]
    begin
    a := array_init(3, 3, 0)  -- this function doesn't exist, ??

Any ideas?  I guess I can do a series of appends or make some text
thing, but that seems awkward...

Tx

pgsql-general by date:

Previous
From: mark
Date:
Subject: Re: select query takes 13 seconds to run with index
Next
From: Volkan YAZICI
Date:
Subject: Permission Problem for DELETE