Re: Pipelined functions in Postgres
- From: "Shoaib Mir" <shoaibmir(at)gmail(dot)com>
- To: "Milen Kulev" <makulev(at)gmx(dot)net>
- Cc: pgsql-performance(at)postgresql(dot)org
- Subject: Re: Pipelined functions in Postgres
- Date: Wed, 20 Sep 2006 02:05:17 +0500
- Message-id: <bf54be870609191405l5abc171cuc805c43bba0b0c42(at)mail(dot)gmail(dot)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)
Home |
Main Index |
Thread Index