Samuel Dussault <Samuel.Dussault@USherbrooke.ca> writes:
> I encounter a problem when creating a procedure using the begin atomic syntax in a script encapsulated in a DO block.
Whenexecuting the DO block, the parser throws a syntax error. I would expect to be able to create the procedure with
boththe new begin atomic and the old syntax.
> do
> $$
> begin
> create or replace procedure test2()
> language sql
> begin atomic
> insert into example (id) values (1);
> end;
> exception
> when others then
> rollback;
> end
> $$;
The problem here is that "begin" is a reserved word in plpgsql
(and for that matter, so is "end").
I'm not terribly excited about trying to find some kludge that
would make this work, because it would almost certainly break
other cases. I'd suggest doing the "create procedure" step
via EXECUTE, so that you can hide "begin ... end" from the
plpgsql parser in a string literal.
regards, tom lane