From: Donald Fraser <demolish@cwgsy.net>
To: [ADMIN] <pgsql-admin@postgresql.org>
Subject: Arrays in pl/pgsql functions
Date: Thu, 17 Jul 2003 12:21:16 +0100
Message-ID: <005701c34c55$8d017540$1664a8c0@DEMOLITION> (raw)
PostgreSQL version 7.3.3
With reference to pl/pgsql functions.
I can declare a function to return an array type and I get no complaints when
defining or executing it.
I can declare a variable within the function as an array type and I don't get
any complaints defining or executing the function.
When I try to access the array I have problems.
I cannot find any documentation on accessing array types so I assumed they
would follow the pgSQL notation of for example:
CREATE OR REPLACE FUNCTION test_arrays() RETURNS int4[] AS '
DECLARE
test int4[];
BEGIN
test[1] := 1;
RETURN test;
END ' LANGUAGE 'plpgsql';
If I try to execute this function I get:
WARNING: plpgsql: ERROR during compile of test_arrays near line 5
ERROR: syntax error at or near "["
If I comment out the line:
test[1] := 1;
then the function executes ok.
Could someone be please inform me what the correct syntax for accessing arrays
is or tell me if its not possible with pl/pgSQL functions.
Thanks in advance,
Donald Fraser.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: demolish@cwgsy.net
Subject: Re: Arrays in pl/pgsql functions
In-Reply-To: <005701c34c55$8d017540$1664a8c0@DEMOLITION>
References: <005701c34c55$8d017540$1664a8c0@DEMOLITION>
* 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