one pl/pgsql question

From: Ewald Geschwinde <webmaster(at)geschwinde(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: one pl/pgsql question
Date: 2002-01-19 15:20:32
Message-ID: 3C498EC0.7060706@geschwinde.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


CREATE FUNCTION cashint(int4) RETURNS text AS '
DECLARE
value ALIAS for $1;
result text;
BEGIN
result=value::text;
RETURN result;
END;
' LANGUAGE 'plpgsql';

select cashint(2);
cashint
---------
2
(1 row)

this is correct nut when I' trying to get an array as return value it
throws an error

CREATE FUNCTION cashint(int4) RETURNS text[] AS '
DECLARE
value ALIAS for $1;
result text[];
BEGIN
result[1]=value::text;
RETURN result;
END;
' LANGUAGE 'plpgsql';

select cashint(2);
NOTICE: plpgsql: ERROR during compile of cashint near line 5
ERROR: parse error at or near "["

Is an array in this use not supported or am I totally wrong?

Ewald

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2002-01-19 17:41:30 Re: one pl/pgsql question
Previous Message mlw 2002-01-19 14:02:43 Re: [NOVICE] Functions in C with Ornate Data Structures