9. Managing Transactions

By default, DML statements like INSERT, UPDATE and DELETE are not committed.

The node-oracledb add-on implements connection.commit() and connection.rollback() methods that can be used to explicitly control transactions.

If the autoCommit property is set to true, then a commit occurs at the end of each execute() or executeMany() call. Unlike an explicit commit(), this does not require a round-trip to the database. For maximum efficiency, set autoCommit to true for the last execute() or executeMany() call of a transaction in preference to using an additional, explicit commit() call.

When connection.executeMany() is used with the batchErrors flag, autoCommit will be ignored if there are data errors. See Handling Data Errors.

When a connection is released, any ongoing transaction will be rolled back. Therefore if a released, pooled connection is re-used by a subsequent pool.getConnection() call (or oracledb.getConnection() call that uses a pool), then any DML statements performed on the obtained connection are always in a new transaction.

When an application ends, any uncommitted transaction on a connection will be rolled back.

Support for distributed transactions is discussed in Two-Phase Commits (TPC).

Note: Oracle Database will implicitly commit when a DDL statement like CREATE is executed irrespective of the value of autoCommit.