Returning an array form a function - Mailing list pgsql-general

From nutgg001@sneakemail.com (Ones Self)
Subject Returning an array form a function
Date
Msg-id a2122d77.0303221158.6514350f@posting.google.com
Whole thread Raw
Responses Re: Returning an array form a function  (Joe Conway <mail@joeconway.com>)
List pgsql-general
Hi,

I'm trying to return an array from a postgres function, but I keep
getting weird errors:

-- this works
CREATE OR REPLACE FUNCTION test(float4[])
 RETURNS float4[]
AS '
BEGIN
 RETURN $1;
END;'
LANGUAGE 'plpgsql';

select test('{1,2}');

-- but I want to change the values in the array:
CREATE OR REPLACE FUNCTION test(float4[])
 RETURNS float4[]
AS '
DECLARE
 a_return[] float4;
 -- a_return[2] float4;
BEGIN
 a_return[1] := 1;
 select 2 into a_return[2];
 RETURN a_return;
END;'
LANGUAGE 'plpgsql';



I just can't seem to declare an array.  How should I be doing this?

pgsql-general by date:

Previous
From: Dave Cramer
Date:
Subject: Re: [HACKERS] Please clarify with regard to Renaming a Sequence
Next
From: msmouse@kittymail.com (Chuck Roast)
Date:
Subject: Re: XML in PostgreSQL