Returning an array form a function

From: nutgg001(at)sneakemail(dot)com (Ones Self)
To: pgsql-general(at)postgresql(dot)org
Subject: Returning an array form a function
Date: 2003-03-22 19:58:42
Message-ID: a2122d77.0303221158.6514350f@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-03-22 20:04:13 Re: 32/64-bit transaction IDs?
Previous Message Ed L. 2003-03-22 19:57:01 Re: 32/64-bit transaction IDs?