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 1uuZBt-00Ckvo-Ht for pgsql-general@arkaria.postgresql.org; Fri, 05 Sep 2025 16:21:34 +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 1uuZBp-008eg7-Uh for pgsql-general@arkaria.postgresql.org; Fri, 05 Sep 2025 16:21:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uuZBp-008efz-Ek for pgsql-general@lists.postgresql.org; Fri, 05 Sep 2025 16:21:29 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uuZBn-000hs9-2r for pgsql-general@lists.postgresql.org; Fri, 05 Sep 2025 16:21:28 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-55f6b0049fbso2683614e87.0 for ; Fri, 05 Sep 2025 09:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757089281; x=1757694081; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FdeYIEZu64l4FBcts2SQJIuQg6kExQnYBJF/h/EqpR0=; b=gkeiZB4Vy/Cexbqa2pgFU/5A+P+YyAJpfSsm1V0VLVN+3zAxRSw5EeZYyY5Kku1lvw WBVt0OA2hNSbX0YFNruA8IMHqpQBHjG05E/D6cPDTiWPfFgNJW2KXKltImAdLnZJqowM LcWwPWO49tpEF+btGDWMjKdi2Yxjl+HrGTbiIOaaKfu8+AZ9gPMelQ9U7zy/wjWqhbYN wo9DXFfEA3wu4JpFMBp/e98K8XmtOUafT/ptnIYvv92KqjC7hGiZOdE5H6LQzg0s8E4I 6ZbFuvDZF0iC3EJqiTeLSgELIc0Ec8XM96mtlIw17QEAsxD/SWd6BaxjFgRVSEZkSZax bn6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757089281; x=1757694081; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FdeYIEZu64l4FBcts2SQJIuQg6kExQnYBJF/h/EqpR0=; b=teYEEh3LnhoRcssxyRj5YlYU2vqlyj12Bm10F8wxff7ioQMlfzHYJD7K3+DwIzYE1z f7RH3rfSX1wwkyVyIjVQ73WsV49rXV1jmxHfccY3rOh5GovrrSWAXV7tlTFpQBFfc809 OBCP6APzWTv5RAsx0yBQPkBo+tNufUwASbCoSHDtyiqgyRU6nhc0wVREV6VO5LgAexxW IoXf1+c+KfK610f+qSzZa7GyQ+E3h/KkwCDNowu67CpHn9dJThxQtZb9pvtwUKPdOHAT jZqydmj8mQWXz9pqD9Z1jFGE2qqjzxCLmhgf6JLSohjAUSSvy0t1OhOK+FsYikb7o3k6 gQXA== X-Gm-Message-State: AOJu0Yy+gouXwaAoxJiYPu4lieoku8pgh3Jq3zWBHHjWPbxB//wWj0O+ HUnhcxDB7I+Q7eCDoOzNNqFPL1V36Cqhkfh1i0jnptbv8zrvg9oau/kZbG5jRgRdJ3WKgO6KAnq sfZy/kbPDX17joJt2+E9u2sIoHTatYK4= X-Gm-Gg: ASbGncvTE5knMVfYGZAwrxmLro/8eMFtbavF7Nt3mQE3ayc6ixXfMizBtNQmjZeiTcZ BkFi1NpDOMpgPIHIbG4KIp/4FvysCpuuMId0iY98lMGcPzFbTceHzP3A5WuYsBhx2j5F4NEcoy9 JnqdnPt+iSuFQ9voJCy19JxjlVllZzY8uKy88AidZiO7bJMpZ8GfHRp1WKemWCiqOrvV1jDY4ME 9x8eVGsqZwQEyYxiXErxeSvSkG8B7ef08ut5hiVcs3MQohQH2vHj+XA/s42DVtcwOesKfLO X-Google-Smtp-Source: AGHT+IHJJOleCXvB8M0jaJ1mWl2SgmbPZ0RsnaYI9gf1UiPPd3udQTVSXuvpYGkqUcMO0w/pzx/insf1gOylpAGgXdg= X-Received: by 2002:a05:6512:260e:b0:55f:493c:ba2b with SMTP id 2adb3069b0e04-55f7097a562mr6007476e87.49.1757089280598; Fri, 05 Sep 2025 09:21:20 -0700 (PDT) MIME-Version: 1.0 References: <1985501673.206991527.1757078030654.JavaMail.zimbra@meteo.fr> In-Reply-To: <1985501673.206991527.1757078030654.JavaMail.zimbra@meteo.fr> From: Merlin Moncure Date: Fri, 5 Sep 2025 10:21:08 -0600 X-Gm-Features: Ac12FXyl9jdyIdHTvJXNJvGNuZklGcVGTWjEslqpVcWBIKp2K_DuMZhbS2CCdV8 Message-ID: Subject: Re: PostgreSQL include directive in plpgsql language PL/pgSQL To: PALAYRET Jacques Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000068a6b9063e103a61" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000068a6b9063e103a61 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Sep 5, 2025 at 7:14=E2=80=AFAM PALAYRET Jacques wrote: > Hello, > > In a PL/pgSQL function, there is no command for sharing a common 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 associated with several other parameters, some numeric and other= s > textual. > It would not be practical for maintenance to have several functions (one > function for each given parameter) with much of the code being identical. > > Presently, I have a text function with all the parameters in return and a > function for each parameter based on the first one (with all the > parameters), using substr(), position(), etc. > For me, I think it would be easier (and perhaps faster) to use some kind > of #include in the body of all the functions. > Can you provide some examples of what you are trying to accomplish? There may be some workarounds using immutable functions other tricks, but I'm not 100% sure I have my head around your issue. merlin --00000000000068a6b9063e103a61 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Sep 5, 2025 at 7:14=E2=80=AFAM PA= LAYRET Jacques <jacques.pal= ayret@meteo.fr> wrote:
Hell= o,

In a PL/pgSQL function, there is no command for sharing a common = 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 associated wit= h several other parameters, some numeric and others textual.
It would no= t be practical for maintenance to have several functions (one function for = each given parameter) with much of the code being identical.

Present= ly, I have a text function with all the parameters in return and a function= for each parameter based on the first one (with all the parameters), using= substr(), position(), etc.
For me, I think it would be easier (and perh= aps faster) to use some kind of #include in the body of all the functions.<= /div>

=C2=A0Can you provide som= e examples of what you are trying to=C2=A0accomplish?

<= div>There may be some workarounds using immutable functions other tricks, b= ut I'm not 100% sure I have my head around your issue.

merlin
--00000000000068a6b9063e103a61--