Declaring arrays in plpgsql functions - Mailing list pgsql-sql

From Daniel Lundin
Subject Declaring arrays in plpgsql functions
Date
Msg-id 20020325100455.GD3337@shire
Whole thread Raw
Responses Re: Declaring arrays in plpgsql functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
I'm trying to convert rows from a table into a two dimensional array, and
thought I could do so in a plpgsql function, but I can't declare the return
variable as an array:

create function reservationIds(int4) returns text[][] as '   declare     paramOriginalResNr        alias for $1;
     rs                        record;
     id_src                    text[][];
   begin     for rs in       select         src,         id       from         ReservationId       where
originalResNr= paramOriginalResNr     loop       text[array_dim(text) + 1][0] := rs.src;       text[array_dim(text) +
1][1]:= rs.id;     end loop;
 
     return id_src;   end; '
language 'plpgsql';

, but when I select the function the parser complains: 'ERROR:  parse error at
or near "["'. It seems to be the id_src declaration that's not correct; the
returns text[][] works.

I've tried text[2][30] to the same effect.

/Daniel



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: About EXECUTE in pl/pgsql
Next
From: "jack"
Date:
Subject: Re: About temporary table