Re: function returning array

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dennis" <pg-user(at)calico-consulting(dot)com>
Cc: "postgres SQL" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: function returning array
Date: 2004-04-14 03:30:47
Message-ID: 29772.1081913447@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Dennis" <pg-user(at)calico-consulting(dot)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 = abc
foo
-----
abc
(1 row)

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2004-04-14 04:10:15 Re: function returning array
Previous Message Dennis 2004-04-13 22:41:52 function returning array