From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
---|---|
To: | "Dirschel, Steve" <steve(dot)dirschel(at)thomsonreuters(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Trying to dynamically create a procedure |
Date: | 2025-03-28 07:12:32 |
Message-ID: | 948bd37078a5b45e101765f30bae25b651ca76f7.camel@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2025-03-26 at 20:27 +0000, Dirschel, Steve wrote:
> DO $$
>
> BEGIN
>
> EXECUTE 'create or replace procedure junk.test_proc() ' ||
> 'LANGUAGE plpgsql ' ||
> 'AS $$ ' ||
> 'declare ' ||
> ' v_cnt integer := 0; ' ||
> 'begin ' ||
> ' raise notice 'v_cnt is %', v_cnt; ' ||
> 'end $$';
>
> END;
>
> $$
>
> It throws this error:
>
> ERROR: syntax error at or near "$$
> DO $$"
> LINE 1: $$
> ^
> dbtest=>
> dbtest=> END;
> WARNING: there is no transaction in progress
> COMMIT
If you nest dollar quotes, you need to use different strings between the dollars:
DO $do$
BEGIN
EXECUTE 'CREATE PROCEDURE ... AS $fun$ ... $fun$';
END;
$do$;
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2025-03-28 07:17:04 | Re: COLLATION update in 13.1 |
Previous Message | Matthias Apitz | 2025-03-28 06:37:49 | Re: COLLATION update in 13.1 |