On 30/10/2018 15:03, p.pierotti@mmbb.it wrote:
> I thought that the “BEGIN/END” block was used to create new transactions
> and that each of them could be managed individually.
In PL/pgSQL, BEGIN/END just create syntactic blocks, they don't manage
transactions.
COMMIT and ROLLBACK manage top-level transactions, but those cannot be
nested (since they are top-level).
In order to create a nested transaction structure, you need to use
subtransactions. In PL/pgSQL, you can use BEGIN/END blocks with an
exception clause to create subtransactions.
I'm not sure what your code is actually trying to do, but you might need
to reorganize it a bit.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services