X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id AB4E69FB2B6 for ; Tue, 19 Sep 2006 18:08:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 99803-05 for ; Tue, 19 Sep 2006 21:08:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.227]) by postgresql.org (Postfix) with ESMTP id AAFF39FB2D2 for ; Tue, 19 Sep 2006 18:08:05 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id h27so5759440wxd for ; Tue, 19 Sep 2006 14:08:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=NDv4ibxSZhkIx+z5mLy+l96gxsvji9WixAPM9XWJ9m9PV+kpJCcl22fGzK8U9GAyH3WdrXXq8wUofs0HdV6Fdk08fRYH/HQRPJr4PUtJarp80M4nvs7eVMQKY4vpJ+LlgikQMEbCz38WQb16nPAWEaeatYEkoHln4kI8fVDYwVM= Received: by 10.70.95.19 with SMTP id s19mr23172807wxb; Tue, 19 Sep 2006 14:07:59 -0700 (PDT) Received: by 10.70.71.8 with HTTP; Tue, 19 Sep 2006 14:07:58 -0700 (PDT) Message-ID: Date: Tue, 19 Sep 2006 14:07:58 -0700 From: "Talha Khan" To: "Milen Kulev" Subject: Re: Pipelined functions in Postgres Cc: pgsql-performance@postgresql.org In-Reply-To: <005701c6dc2c$49011fc0$0a00a8c0@trivadis.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_200522_7040015.1158700078787" References: <005701c6dc2c$49011fc0$0a00a8c0@trivadis.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.696 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, HTML_40_50, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/259 X-Sequence-Number: 20945 ------=_Part_200522_7040015.1158700078787 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Milen, Pipelined function is a code that acts like a database table. Inorder to use this functionality in postgres you would need to write the function like this CREATE OR REPLACE FUNCTION get_test_data (numeric) RETURNS SETOF RECORD AS $$ DECLARE temp_rec RECORD; BEGIN FOR temp_rec IN (SELECT ename FROM emp WHERE sal > $1) LOOP RETURN NEXT temp_rec; END LOOP; RETURN; END; $$ LANGUAGE plpgsql; now inorder to call this function you would write the code as follows SELECT * FROM get_test_data(1000) AS t1 (emp_name VARCHAR); Regards Talha Amjad On 9/19/06, Milen Kulev 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_CRITERIA:4447489221109 > > 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 > ------=_Part_200522_7040015.1158700078787 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hi Milen,
 
Pipelined function is a code that acts like a database table.
 
Inorder to use this functionality in postgres you would need to write the function like this
 
CREATE OR REPLACE FUNCTION get_test_data (numeric)
    RETURNS SETOF RECORD AS
$$
DECLARE
    temp_rec    RECORD;
BEGIN
    FOR temp_rec IN (SELECT ename FROM emp WHERE sal > $1)
    LOOP
        RETURN NEXT temp_rec;
    END LOOP;
    RETURN;
END;
$$ LANGUAGE plpgsql;
 
now inorder to call this function you would write the code as follows
 
SELECT * FROM get_test_data(1000) AS t1 (emp_name VARCHAR);
 
 
Regards
Talha Amjad


 
On 9/19/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_CRITERIA:4447489221109

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

------=_Part_200522_7040015.1158700078787--