From: Dennis <pg-user@calico-consulting.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: function returning array
Date: Thu, 15 Apr 2004 08:16:02 -0400
Message-ID: <courier.407E7D02.00006AB1@wolverine.lercnetworks.com> (raw)
In-Reply-To: <29772.1081913447@sss.pgh.pa.us>
References: <courier.407C6CB0.00005135@wolverine.lercnetworks.com>
<29772.1081913447@sss.pgh.pa.us>
Tom Lane writes:
> "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?
pg 7.4.1
I should have listed the source for the function. Here is a simplified
parseString function and the foo that calls it.
dennis=# create or replace function parseString (varchar, varchar)
dennis-# RETURNS varchar[] AS '
dennis'# DECLARE
dennis'# pParsed varchar[];
dennis'# pString ALIAS FOR $1;
dennis'# pSeparator ALIAS FOR $2;
dennis'# begin
dennis'#
dennis'# -- example simplified
dennis'# pParsed[1] = ''blah'';
dennis'# pParsed[2] = ''hrmmph'';
dennis'#
dennis'# return pParsed;
dennis'# END;
dennis'# ' language plpgsql;
CREATE FUNCTION
dennis=#
dennis=# create or replace function foo() returns varchar as '
dennis'# declare
dennis'# results varchar[];
dennis'# tmpv varchar;
dennis'# begin
dennis'# results := parseString(''asdf'',''asdf'');
dennis'# tmpv := results[1];
dennis'# RAISE NOTICE '' tmpv = % '',tmpv;
dennis'# return tmpv;
dennis'# end' language plpgsql;
CREATE FUNCTION
dennis=# select foo();
NOTICE: tmpv = <NULL>
foo
-----
(1 row)
Dennis
pg-user@calico-consulting.com
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: pg-user@calico-consulting.com, tgl@sss.pgh.pa.us
Subject: Re: function returning array
In-Reply-To: <courier.407E7D02.00006AB1@wolverine.lercnetworks.com>
* 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