| From: | tuanhoanganh <hatuan05(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | array function problem |
| Date: | 2008-03-17 04:37:16 |
| Message-ID: | c235f61d0803162137g2c0a0efdq31b1d08f6e08ace0@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I have a array function
CREATE OR REPLACE FUNCTION "temp".rowfromarray(text[])
RETURNS SETOF text AS
$BODY$DECLARE
_return text;
BEGIN
for i in 1..array_upper($1,1) loop
_return := $1[i];
return next _return;
end loop;
return;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION "temp".rowfromarray(text[]) OWNER TO postgres;
I call it by command
select temp.rowfromarray(string_to_array('1,2,3,4,5', ','));
but it have error
ERROR: set-valued function called in context that cannot accept a set
CONTEXT: PL/pgSQL function "rowfromarray" line 6 at RETURN NEXT
********** Error **********
ERROR: set-valued function called in context that cannot accept a set
SQL state: 0A000
Context: PL/pgSQL function "rowfromarray" line 6 at RETURN NEXT
When i debug it by pass {1,2,3,4,5} to first parameter, it run well.
Please help me.
Thanks you very much. Sorry for my English.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2008-03-17 04:50:54 | Re: array function problem |
| Previous Message | Adrian Klaver | 2008-03-17 01:27:36 | Re: Updating |