From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Marc Millas <marc.millas@mokadb.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: syntax question
Date: Thu, 3 Jun 2021 14:17:38 -0700
Message-ID: <536d6eda-9ea9-cd49-84a6-25808073e2ce@aklaver.com> (raw)
In-Reply-To: <CADX_1aaU9UCt4guwqp9wWCbJi34EfD3UEwiqVQZjO+3X8zfWZg@mail.gmail.com>
References: <CADX_1aa=8woWOoOzo0iMjvkFkJC1=31+fziMaAUfFu4u7d0_xg@mail.gmail.com>
<20210603190108.GC22019@momjian.us>
<c58b04ac-e713-f089-8400-763a742bf86d@aklaver.com>
<CADX_1aaU9UCt4guwqp9wWCbJi34EfD3UEwiqVQZjO+3X8zfWZg@mail.gmail.com>
On 6/3/21 1:01 PM, Marc Millas wrote:
> thanks Adrian, exactly what I was missing :-)
>
> about knowing if I should...
> We have to create a set of triggers (insert, update, delete) within a
> huge set of tables. and that list of tables, and structure of them can
> be customized, maintained, ...
> so we were looking for a standard script to automatize the building of
> the whole thing, taking list of columns and constraints (for PK)
> directly from pg_catalog.
> Now it works :-)
>
> but.. why do you ask that question ? is there any king of hidden wolf we
> didnt see ?
See David Johnston's answer. Nested quoting will drive you to drink(or
drink more):)
>
>
> Marc MILLAS
> Senior Architect
> +33607850334
> www.mokadb.com <http://www.mokadb.com;
>
>
>
> On Thu, Jun 3, 2021 at 9:11 PM Adrian Klaver <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com>> wrote:
>
> On 6/3/21 12:01 PM, Bruce Momjian wrote:
> > On Thu, Jun 3, 2021 at 08:58:03PM +0200, Marc Millas wrote:
> >> Hi,
> >>
> >> within a function, I want to create another function.
> >> no pb.
> >> but if I write:
> >> declare bidule text;
> >> begin
> >> bidule:='myfunc';
> >> create function bidule() ...
> >>
> >>
> >> it does create a function named bidule and not myfunc.
> >> so I am obviously missing something too obvious.
> >
> > You can't create functions inside of functions; same for procedures.
> >
>
> Sure you can:
>
> CREATE OR REPLACE FUNCTION public.test_fnc()
> RETURNS void
> LANGUAGE plpgsql
> AS $function$
> DECLARE
> bidule text;
> BEGIN
> bidule:='myfunc';
> EXECUTE 'create function ' || bidule || '() RETURNS void language
> plpgsql AS $fnc$ BEGIN END; $fnc$ ';
> END;
>
>
> $function$
>
> select test_fnc();
> test_fnc
> ----------
>
> \df myfunc
> List of functions
> Schema | Name | Result data type | Argument data types | Type
> --------+--------+------------------+---------------------+------
> public | myfunc | void | | func
>
>
> Whether you should is another question.
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, marc.millas@mokadb.com, bruce@momjian.us
Subject: Re: syntax question
In-Reply-To: <536d6eda-9ea9-cd49-84a6-25808073e2ce@aklaver.com>
References: <CADX_1aa=8woWOoOzo0iMjvkFkJC1=31+fziMaAUfFu4u7d0_xg@mail.gmail.com> <20210603190108.GC22019@momjian.us> <c58b04ac-e713-f089-8400-763a742bf86d@aklaver.com> <CADX_1aaU9UCt4guwqp9wWCbJi34EfD3UEwiqVQZjO+3X8zfWZg@mail.gmail.com> <536d6eda-9ea9-cd49-84a6-25808073e2ce@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox