Re: Trying to dynamically create a procedure

2025-04-05 Thread Laurenz Albe
On Wed, 2025-03-26 at 20:27 +, Dirschel, Steve wrote: > DO $$ >   > BEGIN >   > EXECUTE 'create or replace procedure junk.test_proc() ' || >   'LANGUAGE plpgsql  '  || >   'AS $$ '    || >   'declare  '  || >   '  v_cnt

Trying to dynamically create a procedure

2025-03-26 Thread Dirschel, Steve
Hi, I have the need to dynamically create a procedure. Here is a simple procedure: create or replace procedure junk.test_proc() LANGUAGE plpgsql AS $$ declare v_cnt integer := 0; begin raise notice 'v_cnt is %', v_cnt; end $$; That creates and runs fine. Here I’m trying to create i

Re: Trying to dynamically create a procedure

2025-03-26 Thread Christophe Pettus
> On Mar 26, 2025, at 13:27, Dirschel, Steve > wrote: > > I think the problem has to do with having AS $$ and END $$ with the 2 $’s. PostgreSQL's multiline-string syntax is quite flexible. You can do things like: DO $doblock$ ... $doblock$ LANGUAGE plpgsql; I tend to put the name of th