Re: Function returning SETOF using plpythonu

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Function returning SETOF using plpythonu
Date: 2007-01-29 14:29:43
Message-ID: 200701290629.43520.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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");
> > return [ (r["name"]) for r in records]
> >' LANGUAGE 'plpythonu';
>
> Then I tried to do some changes and try to return a SETOF type:
> CREATE TYPE "test_python_t" AS (
> name varchar(50)
> );
>
> CREATE FUNCTION "test_python_setof"()
> RETURNS SETOF test_python_t AS '
> records=plpy.execute("SELECT name FROM interface");
> return [ (r["name"]) for r in records]
> ' LANGUAGE 'plpythonu';
>
> And I'm getting ERROR: tuple return types are not supported yet.
>
> On my production database server I'm using PostgreSQL 7.4 and using
> language plpgsql I'm returning some SETOF type without problems.
> Is this a feature that's missing on this version or I'm I doing
> something wrong on code? If is a feature missing, is already implemented
> on some version afterwards?
>
> Best regards,
> Luís Sousa
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
SETOF in pl/pythonu appeared in 8.2

--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2007-01-29 20:21:55 Re: [ADMIN] server process (PID xxx) was
Previous Message Luís Sousa 2007-01-29 14:12:26 Re: Function returning SETOF using plpythonu