Re: Nested funtion

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Sridhar N Bamandlapally <sridhar(dot)bn1(at)gmail(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>, PostgreSQL-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Nested funtion
Date: 2016-03-28 04:28:41
Message-ID: CAKFQuwbN4siMLOV-vmeWCE7gO53La_q3en3UoGWSKJF5HUT_Nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sun, Mar 27, 2016 at 9:14 PM, Sridhar N Bamandlapally <
sridhar(dot)bn1(at)gmail(dot)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.


In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sterpu Victor 2016-03-28 06:32:17 Unique values on multiple tables
Previous Message Pavel Stehule 2016-03-28 04:27:21 Re: [HACKERS] Nested funtion

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-03-28 04:49:46 Re: silent data loss with ext4 / all current versions
Previous Message Pavel Stehule 2016-03-28 04:27:21 Re: [HACKERS] Nested funtion