Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uuWGJ-00BZR0-Uw for pgsql-general@arkaria.postgresql.org; Fri, 05 Sep 2025 13:13:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uuWGJ-007bLI-1x for pgsql-general@arkaria.postgresql.org; Fri, 05 Sep 2025 13:13:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uuWGI-007bKf-NC for pgsql-general@lists.postgresql.org; Fri, 05 Sep 2025 13:13:55 +0000 Received: from zcsmtaf02-pub.meteo.fr ([137.129.63.6]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uuWGF-000iP6-1h for pgsql-general@lists.postgresql.org; Fri, 05 Sep 2025 13:13:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by zcsmtaf02-pub.meteo.fr (Postfix) with ESMTP id 45F1B4000934 for ; Fri, 5 Sep 2025 13:13:51 +0000 (GMT) Received: from zcsmtaf02-pub.meteo.fr ([127.0.0.1]) by localhost (zcsmtaf02.meteo.fr [127.0.0.1]) (amavis, port 10032) with ESMTP id qg0_wzRiIjCg for ; Fri, 5 Sep 2025 13:13:51 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcsmtaf02-pub.meteo.fr (Postfix) with ESMTP id 2CF954543D19 for ; Fri, 5 Sep 2025 13:13:51 +0000 (GMT) X-Virus-Scanned: amavis at meteo.fr Received: from zcsmtaf02-pub.meteo.fr ([127.0.0.1]) by localhost (zcsmtaf02.meteo.fr [127.0.0.1]) (amavis, port 10026) with ESMTP id W8T4SpHtRYS0 for ; Fri, 5 Sep 2025 13:13:51 +0000 (GMT) Received: from zcsmsm04.meteo.fr (zcsmsm04.meteo.fr [172.24.3.124]) by zcsmtaf02-pub.meteo.fr (Postfix) with ESMTP id 188F04000934 for ; Fri, 5 Sep 2025 13:13:51 +0000 (GMT) Date: Fri, 5 Sep 2025 13:13:50 +0000 (GMT) From: PALAYRET Jacques To: pgsql-general@lists.postgresql.org Message-ID: <1985501673.206991527.1757078030654.JavaMail.zimbra@meteo.fr> Subject: PostgreSQL include directive in plpgsql language PL/pgSQL MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_27d375a0-08fe-4c8c-971e-bea59b39dbad" X-Originating-IP: [172.24.2.157] X-Mailer: Zimbra 9.0.0_GA_4583 (ZimbraWebClient - FF128 (Win)/9.0.0_GA_4583) Thread-Index: ITWoMjlG0cq7Y46hVWTQDUO2a6wugQ== Thread-Topic: PostgreSQL include directive in plpgsql language PL/pgSQL List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_27d375a0-08fe-4c8c-971e-bea59b39dbad Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello,=20 In a PL/pgSQL function, there is no command for sharing a common part of th= e body of several functions, is there?=20 In my case, I would like a function that returns a numeric value; this valu= e is associated with several other parameters, some numeric and others text= ual.=20 It would not be practical for maintenance to have several functions (one fu= nction for each given parameter) with much of the code being identical.=20 Presently, I have a text function with all the parameters in return and a f= unction for each parameter based on the first one (with all the parameters)= , using substr(), position(), etc.=20 For me, I think it would be easier (and perhaps faster) to use some kind of= #include in the body of all the functions.=20 Is there an equivalent of #include (include directive) in functions (writte= n in plpgsql language)?=20 Regards=20 ----- M=C3=A9t=C3=A9o-France -----=20 PALAYRET Jacques=20 --=_27d375a0-08fe-4c8c-971e-bea59b39dbad Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello,

In a PL/pgSQL function, there is no command for sharing a c= ommon part of the body of several functions, is there?

In my case, I= would like a function that returns a numeric value; this value is associat= ed with several other parameters, some numeric and others textual.
It wo= uld not be practical for maintenance to have several functions (one functio= n for each given parameter) with much of the code being identical.

P= resently, I have a text function with all the parameters in return and a fu= nction for each parameter based on the first one (with all the parameters),= using substr(), position(), etc.
For me, I think it would be easier (an= d perhaps faster) to use some kind of #include in the body of all the funct= ions.

Is there an equivalent of #include (include directive) in func= tions (written in plpgsql language)?

Regards
----- M=C3=A9t=C3=A9o-France -----
PALAYRET Jacques
=
--=_27d375a0-08fe-4c8c-971e-bea59b39dbad--