From: | "Dennis" <pg-user(at)calico-consulting(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "postgres SQL" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: function returning array |
Date: | 2004-04-15 12:16:02 |
Message-ID: | courier.407E7D02.00006AB1@wolverine.lercnetworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Tom Lane writes:
> "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?
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(at)calico-consulting(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Charles Wilt | 2004-04-15 13:50:09 | Re: Database triggers |
Previous Message | Martin Marques | 2004-04-15 11:30:20 | Re: problem porting MySQL SQL to Postgres |