Re: syntax question

Поиск
Список
Период
Сортировка
Искать
От
Guyren Howe
Тема
Re: syntax question
Дата
Msg-id
6eb49ebf-4d6f-46f5-8e48-f3b870c31a2f@Spark
Ответ на
Re: syntax question (Bruce Momjian)
Список
Дерево обсуждения
syntax question Marc Millas <marc.millas@mokadb.com>
Re: syntax question Bruce Momjian <bruce@momjian.us>
Re: syntax question Adrian Klaver <adrian.klaver@aklaver.com>
Re: syntax question Tom Lane <tgl@sss.pgh.pa.us>
Re: syntax question Bruce Momjian <bruce@momjian.us>
Re: syntax question Guyren Howe <guyren@gmail.com>
inner subprograms ... Was: syntax question Bryn Llewellyn <bryn@yugabyte.com>
Re: syntax question Marc Millas <marc.millas@mokadb.com>
Re: syntax question Marc Millas <marc.millas@mokadb.com>
Re: syntax question Adrian Klaver <adrian.klaver@aklaver.com>
Re: syntax question Marc Millas <marc.millas@mokadb.com>
Re: syntax question "David G. Johnston" <david.g.johnston@gmail.com>
Re: syntax question Marc Millas <marc.millas@mokadb.com>
I know it would be non-standard, but I would love to see Postgres support the likes of nested functions.

I know that would be non-standard, but Postgres has lots of non-standard features that make it more like a real programming language and considerably more productive.
On Jun 3, 2021, 12:34 -0700, Bruce Momjian <bruce@momjian.us>, wrote:
On Thu, Jun 3, 2021 at 03:21:15PM -0400, Tom Lane wrote:
Adrian Klaver <adrian.klaver@aklaver.com> writes:
On 6/3/21 12:01 PM, Bruce Momjian wrote:
On Thu, Jun 3, 2021 at 08:58:03PM +0200, Marc Millas wrote:
within a function, I want to create another function.

You can't create functions inside of functions; same for procedures.

Sure you can:

Yeah. The actual problem here is that Marc is expecting variable
substitution to occur within a utility (DDL) statement, which it
doesn't. The workaround is to build the command as a string and
use EXECUTE, as Adrian illustrated:

EXECUTE 'create function ' || bidule || '() RETURNS void language
plpgsql AS $fnc$ BEGIN END; $fnc$ ';

This is not terribly well explained in the existing docs. I tried
to improve the explanation awhile ago in HEAD:

https://www.postgresql.org/docs/devel/plpgsql-statements.html#PLPGSQL-STATEMENTS-GENERAL-SQL

Oh, I thought he wanted to declare a function inside the function that
could be called only by that function, like private functions in Oracle
packages can do. Yes, you can create a function that defines a function
that can be called later. I guess you could also create a function that
_conditionally_ creates a function that it can call itself too. My
point is that you can't create a function that has function scope ---
they all have schema scope.

--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com

If only the physical world exists, free will is an illusion.



В списке pgsql-general по дате отправления
От: Paul Ramsey
Дата:
Сообщение: Re: index unique
От: Marc Millas
Дата:
Сообщение: Re: index unique
FAQ