pg_transaction_status — Get the current in-transaction status


pg_transaction_status conn


pg_transaction_status returns the current status of the connection: whether it is inside a transaction block, outside a transaction block, or inside a failed transaction block. A transaction block begins with the SQL command BEGIN, and ends with one of the SQL commands COMMIT or ROLLBACK. A failed transaction block is a transaction block after any error occurs; PostgreSQL will ignore all SQL commands until the end of the transaction block. pg_transaction_status allows an application to determine if it is in a transaction block or failed transaction block.



The handle of the connection on which to report transaction status.

Return Value

One of the string values in the following table:

IDLEConnection is idle, not in a transaction block.
INTRANSConnection is in a (non-failed) transaction block.
INERRORConnection is in a failed transaction block.
UNKNOWNConnection is bad or in an unknown state.


This command uses or emulates the PostgreSQL libpq function PQtransactionStatus. Logo

This version of the manual was produced for the Pgtcl-ng Sourceforge project web service site, which requires the logo on each page.

To download a logo-free copy of the manual, see the Pgtcl-ng project downloads area.