Re: PostgreSQL include directive in plpgsql language PL/pgSQL

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)fr>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL include directive in plpgsql language PL/pgSQL
Date: 2025-09-05 16:21:08
Message-ID: CAHyXU0zNE3CuPs2433GZtVh9SbrkyTUwGmAiy+yJuhz484gPUw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 5, 2025 at 7:14 AM PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)fr>
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 others
> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2025-09-05 16:36:05 Re: PostgreSQL include directive in plpgsql language PL/pgSQL
Previous Message Tom Lane 2025-09-05 13:56:57 Re: PostgreSQL include directive in plpgsql language PL/pgSQL