one pl/pgsql question - Mailing list pgsql-novice

From Ewald Geschwinde
Subject one pl/pgsql question
Date
Msg-id 3C498EC0.7060706@geschwinde.net
Whole thread Raw
Responses Re: one pl/pgsql question  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Functions in C with Ornate Data Structures
Next
From: Tom Lane
Date:
Subject: Re: one pl/pgsql question