Re: Nested funtion - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Nested funtion
Date
Msg-id CAKFQuwbN4siMLOV-vmeWCE7gO53La_q3en3UoGWSKJF5HUT_Nw@mail.gmail.com
Whole thread Raw
In response to Nested funtion  (Sridhar N Bamandlapally <sridhar.bn1@gmail.com>)
List pgsql-hackers
On Sun, Mar 27, 2016 at 9:14 PM, Sridhar N Bamandlapally <sridhar.bn1@gmail.com> wrote:
Hi

Is there any way to create nested function?

oracle to postgres migration required super function variable reference into nested function without nested function parameter

Oracle sample:
-------------------------------
create or replace function f1(n number) return number
is
    vs number:=1;
    function nf1(m number) return number is
    begin
        return vs + m + n;
    end;
begin
    return nf1(2);
end;
/

run:
--------
SQL> select f1(9) from dual;

     F1(9)
----------
        12


PostgreSQL's ​pl/pgsql langauge doesn't grok closures.  You are welcome to write "f1" in a language that does.  Perl and Python are built-in and many others are available.  I assume at least one of them can do this.

​David J.

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Nested funtion
Next
From: Michael Paquier
Date:
Subject: Re: silent data loss with ext4 / all current versions