| From: | Marc Millas <marc(dot)millas(at)mokadb(dot)com> | 
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
| Cc: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> | 
| Subject: | Re: syntax question | 
| Date: | 2021-06-03 19:53:40 | 
| Message-ID: | CADX_1aY16brkZF+jz24V86dC9UqZ-fdxd6vUyqtyAjPzGAHgRA@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
good reading, thanks
Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com
On Thu, Jun 3, 2021 at 9:21 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)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
>
>                         regards, tom lane
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Marc Millas | 2021-06-03 20:01:44 | Re: syntax question | 
| Previous Message | Bruce Momjian | 2021-06-03 19:34:44 | Re: syntax question |