Re: function returning array - Mailing list pgsql-sql

From Dennis
Subject Re: function returning array
Date
Msg-id courier.407E7D02.00006AB1@wolverine.lercnetworks.com
Whole thread Raw
In response to Re: function returning array  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: function returning array
List pgsql-sql
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 




pgsql-sql by date:

Previous
From: Martin Marques
Date:
Subject: Re: problem porting MySQL SQL to Postgres
Next
From: Jan Wieck
Date:
Subject: Re: cursors and for loops?