Could some kindly soul point out where this is statement is wrong, please? I'm trying to run a very simple transaction test, but can't even get the statement to run. I'm trying to run it in the SQL Query window of PG Admin. There are no other connections to the database.
DO $$
BEGIN
START TRANSACTION;
UPDATE IsolationTests SET Col1 = 2;
perform pg_sleep(5.0);
ROLLBACK;
EXCEPTION WHEN division_by_zero THEN
BEGIN
END;
END $$;
I want to play around with the transaction level and start and end a transaction in the code. If I comment out the "START TRANSACTION" & "ROLLBACK" the statment runs fine. Uncomment them and I get
"ERROR: cannot begin/end transactions in PL/pgSQL HINT: Use a BEGIN block with an EXCEPTION clause instead."
Uh? It's in a BEGIN ... EXCEPTION block, isn't it??