2 44.8. Transaction Management #
4 In a procedure called from the top level or an anonymous code block (DO
5 command) called from the top level it is possible to control
6 transactions. To commit the current transaction, call plpy.commit(). To
7 roll back the current transaction, call plpy.rollback(). (Note that it
8 is not possible to run the SQL commands COMMIT or ROLLBACK via
9 plpy.execute or similar. It has to be done using these functions.)
10 After a transaction is ended, a new transaction is automatically
11 started, so there is no separate function for that.
14 CREATE PROCEDURE transaction_test1()
17 for i in range(0, 10):
18 plpy.execute("INSERT INTO test1 (a) VALUES (%d)" % i)
25 CALL transaction_test1();
27 Transactions cannot be ended when an explicit subtransaction is active.