I want to run a script inside a transaction in PostgreSQL. So I surround the SQL code with begin and commit statements. But I want to rollback on error. I don't see how to do that.
BEGIN;
UPDATE public.tablename
SET blah = 'xxx'
WHERE thing= '123';
COMMIT;