From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dennis <pg-user@calico-consulting.com>
Cc: postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: function returning array
Date: Tue, 13 Apr 2004 23:30:47 -0400
Message-ID: <29772.1081913447@sss.pgh.pa.us> (raw)
In-Reply-To: <courier.407C6CB0.00005135@wolverine.lercnetworks.com>
References: <courier.407C6CB0.00005135@wolverine.lercnetworks.com>
"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 = abc
foo
-----
abc
(1 row)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, pg-user@calico-consulting.com
Subject: Re: function returning array
In-Reply-To: <29772.1081913447@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox