postgresql_16:5.3.3.3 Managing Transactions
PostgreSQL 16 > Client Interfaces > ECPG — Embedded SQL in C > Running SQL Commands > Managing Transactions
In the default mode, statements are committed only when EXEC SQL COMMIT is issued. The embedded SQL interface also supports autocommit of transactions (similar to psql's default behavior) via the -t command-line option to ecpg (see (see postgresql_16:7.2.6)) or via the EXEC SQL SET AUTOCOMMIT TO ON statement. In autocommit mode, each command is automatically committed unless it is inside an explicit transaction block. This mode can be explicitly turned off using EXEC SQL SET AUTOCOMMIT TO OFF.
The following transaction management commands are available: EXEC SQL COMMIT Commit an in-progress transaction. EXEC SQL ROLLBACK Roll back an in-progress transaction. EXEC SQL PREPARE TRANSACTION *transaction_id* Prepare the current transaction for two-phase commit. EXEC SQL COMMIT PREPARED *transaction_id* Commit a transaction that is in prepared state. EXEC SQL ROLLBACK PREPARED *transaction_id* Roll back a transaction that is in prepared state. EXEC SQL SET AUTOCOMMIT TO ON Enable autocommit mode. EXEC SQL SET AUTOCOMMIT TO OFF Disable autocommit mode. This is the default.