Re: function returning array - Mailing list pgsql-sql

From Tom Lane
Subject Re: function returning array
Date
Msg-id 29772.1081913447@sss.pgh.pa.us
Whole thread Raw
In response to function returning array  ("Dennis" <pg-user@calico-consulting.com>)
Responses Re: function returning array
List pgsql-sql
"Dennis" <pg-user@calico-consulting.com> writes:
> I am trying to return an array from a function and don't seem to be having 
> luck.

Seems to work for me ... what PG version are you using?

regression=# create function parseString() returns varchar[] as
regression-# 'begin return \'{abc,def,ghi}\'; end' language plpgsql;
CREATE FUNCTION
regression=# select parseString(); parsestring
---------------{abc,def,ghi}
(1 row)
regression=# create function foo() returns varchar as '
regression'# declare
regression'#   results varchar[];
regression'#   tmpv varchar;
regression'# begin
regression'#   results := parseString();
regression'#   tmpv := results[1];
regression'#   RAISE NOTICE '' tmpv = % '',tmpv;
regression'#   return tmpv;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select foo();
NOTICE:   tmpv = abcfoo
-----abc
(1 row)
        regards, tom lane


pgsql-sql by date:

Previous
From: "Dennis"
Date:
Subject: function returning array
Next
From: Joe Conway
Date:
Subject: Re: function returning array