Re: Localizing stored functions by replacing placeholders in their body

From: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
To:
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Localizing stored functions by replacing placeholders in their body
Date: 2021-03-02 16:54:44
Message-ID: CAADeyWgrj0JOMJ9cvkketbQ9QCkshJjvGRc9fQQh0WzzsZKN0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you for the \! hint, Pavel, didn't know about that!

Is it possible to have a pure SQL solution? (To avoid having to install
"sed" on my Win 10 PC)

Maybe by using EXECUTE?

EXECUTE REGEXP_REPLACE(
$localize$

CREATE OR REPLACE FUNCTION my_func()
RETURNS text AS
$func$
SELECT '$(placeholder)';
$func$ LANGUAGE sql IMMUTABLE;

$localize$, '\$\(\w+\)', 'English word', 'g');

Unfortunately, I get the error:

ERROR: prepared statement "regexp_replace" does not exist

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2021-03-02 17:00:30 Re: Localizing stored functions by replacing placeholders in their body
Previous Message Pavel Stehule 2021-03-02 16:40:05 Re: Localizing stored functions by replacing placeholders in their body