pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Lundin <daniel@helena-daniel.se>
To: pgsql-sql@postgresql.org
Subject: Declaring arrays in plpgsql functions
Date: Mon, 25 Mar 2002 11:04:55 +0100
Message-ID: <20020325100455.GD3337@shire> (raw)

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




view thread (4+ messages)  latest in thread

Message-ID: <20020325100455.GD3337@shire>
Permalink:  ../20020325100455.GD3337@shire/
Also on:    postgresql.org/message-id/20020325100455.GD3337@shire

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: daniel@helena-daniel.se
  Subject: Re: Declaring arrays in plpgsql functions
  In-Reply-To: <20020325100455.GD3337@shire>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox