On Monday 29 January 2007 6:12 am, Luís Sousa wrote:
> Thanks :-)
> That worked fine.
>
> >plpy.execute returns dictionary, and you need a list. You may try this:
> >
> >CREATE FUNCTION "test_python_setof"()
> >RETURNS SETOF text AS '
> >records=plpy.execute("SELECT name FROM interface");
> >
Thanks :-)
That worked fine.
plpy.execute returns dictionary, and you need a list. You may try this:
CREATE FUNCTION "test_python_setof"()
RETURNS SETOF text AS '
records=plpy.execute("SELECT name FROM interface");
return [ (r["name"]) for r in records]
' LANGUAGE 'plpythonu';
Then
Dnia Fri, 26 Jan 2007 17:24:52 +, Luís Sousa napisał(a):
> Hi,
>
> Is it possible to return rows from a function written in plpythonu using
> SETOF?
>
> Example:
> CREATE FUNCTION "test_python_setof"()
> RETURNS SETOF text AS '
> records=plpy.execute("SELECT name FROM interface");
>
Hi,
Is it possible to return rows from a function written in plpythonu using
SETOF?
Example:
CREATE FUNCTION "test_python_setof"()
RETURNS SETOF text AS '
records=plpy.execute("SELECT name FROM interface");
return records
' LANGUAGE 'plpythonu';
With this code is returning the object fr