From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Localizing stored functions by replacing placeholders in their body |
Date: | 2021-03-02 17:00:30 |
Message-ID: | CAFj8pRD3K8NfoxLCEEnnqirJgkYRXPj2MD2=Le2o1xRu+FT24A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
út 2. 3. 2021 v 17:55 odesílatel Alexander Farber <
alexander(dot)farber(at)gmail(dot)com> napsal:
> 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)
>
You should to use PLpgSQL EXECUTE statement, not SQL statement
https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
But I don't know - all this is server side, and you do some things on
client side
> 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
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Farber | 2021-03-02 17:04:34 | Re: Localizing stored functions by replacing placeholders in their body |
Previous Message | Alexander Farber | 2021-03-02 16:54:44 | Re: Localizing stored functions by replacing placeholders in their body |