pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Luís Sousa <llsousa@ualg.pt>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Function returning SETOF using plpythonu
Date: Mon, 29 Jan 2007 14:12:26 +0000
Message-ID: <45BE00CA.1060106@ualg.pt> (raw)
In-Reply-To: <pan.2007.01.26.22.17.58.397717@gmail.com>
References: <45BA3964.8070704@ualg.pt>
	<pan.2007.01.26.22.17.58.397717@gmail.com>

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




view thread (4+ messages)  latest in thread

Message-ID: <45BE00CA.1060106@ualg.pt>
Permalink:  ../45BE00CA.1060106@ualg.pt/
Also on:    postgresql.org/message-id/45BE00CA.1060106@ualg.pt

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: llsousa@ualg.pt
  Subject: Re: Function returning SETOF using plpythonu
  In-Reply-To: <45BE00CA.1060106@ualg.pt>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox