pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shoaib Mir <shoaibmir@gmail.com>
To: Milen Kulev <makulev@gmx.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Pipelined functions in Postgres
Date: Wed, 20 Sep 2006 02:05:17 +0500
Message-ID: <bf54be870609191405l5abc171cuc805c43bba0b0c42@mail.gmail.com> (raw)
In-Reply-To: <005701c6dc2c$49011fc0$0a00a8c0@trivadis.com>
References: <005701c6dc2c$49011fc0$0a00a8c0@trivadis.com>

I think pipelined functions are code you can pretend is a database table.

For example you can do it like this in Oracle:

select * from PLSQL_FUNCTION;

You can achieve something similar in PostgreSQL using RETURN SETOF functions
like this:

CREATE OR REPLACE FUNCTION test_pipe (int)
    RETURNS SETOF RECORD AS
$$
DECLARE
    v_rec    RECORD;
BEGIN
    FOR temp_rec IN (SELECT col FROM table where col > 10)
    LOOP
        RETURN NEXT v_rec;
    END LOOP;
    RETURN;
END;
$$ LANGUAGE plpgsql;

This function can be called like this:

SELECT * FROM test_pipe(10) AS tbl (col int);

Hope this helps...

Thanks,
-- 
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)


On 9/20/06, Milen Kulev <makulev@gmx.net> wrote:
>
> Hello Lister,
> I am curios whether I can emulate the Oracle pipelined functions
> functionality in PG too (using RETURN NEXT ). For more
> information and examples about Oracle pipelined functions see:
>
> http://asktom.oracle.com/pls/ask/f?p=4950:8:8127757633768425921::NO::F4950_P8_DISPLAYID,F4950_P8_CRI...
>
> I have used  pipeline functions in DWH enviromnent  with success and would
> like
> To use similar concept in PG too.
>
> Any help, examples , links and  shared experiences would be greately
> appreciated.
>
> Best Regards.
> Milen
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly
>

view thread (7+ messages)  latest in thread

Message-ID: <bf54be870609191405l5abc171cuc805c43bba0b0c42@mail.gmail.com>
Permalink:  ../bf54be870609191405l5abc171cuc805c43bba0b0c42@mail.gmail.com/
Also on:    postgresql.org/message-id/bf54be870609191405l5abc171cuc805c43bba0b0c42@mail.gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: shoaibmir@gmail.com, makulev@gmx.net
  Subject: Re: Pipelined functions in Postgres
  In-Reply-To: <bf54be870609191405l5abc171cuc805c43bba0b0c42@mail.gmail.com>
  References: <005701c6dc2c$49011fc0$0a00a8c0@trivadis.com> <bf54be870609191405l5abc171cuc805c43bba0b0c42@mail.gmail.com>

* 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