Re: [SQL] Function returning SETOF using plpythonu

2007-01-29 Thread Adrian Klaver
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"); > >

Re: [SQL] Function returning SETOF using plpythonu

2007-01-29 Thread Luís Sousa
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

Re: [SQL] Function returning SETOF using plpythonu

2007-01-26 Thread Marcin Stępnicki
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"); >

[SQL] Function returning SETOF using plpythonu

2007-01-26 Thread Luís Sousa
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