Firebird 2.5 Language ReferenceFirebird 2.5 Language ReferenceMonitoring Tables → MON$STATEMENTS
Firebird Firebird Prev: MON$RECORD_STATSFirebird 2.5 Language ReferenceUp: Monitoring TablesNext: MON$TRANSACTIONS

MON$STATEMENTS

Table of Contents

Using MON$STATEMENTS to Cancel a Query

MON$STATEMENTS displays statements prepared for execution.

Column Name Data Type Description
MON$STATEMENT_ID INTEGER Statement identifier
MON$ATTACHMENT_ID INTEGER Connection identifier
MON$TRANSACTION_ID INTEGER Transaction identifier
MON$STATE SMALLINT Statement state:
0 - idle
1 - active
2 - stalled
MON$TIMESTAMP TIMESTAMP The date and time when the statement was prepared
MON$SQL_TEXT BLOB TEXT Statement text in SQL
MON$STAT_ID INTEGER Statistics identifier

The STALLED state indicates that, at the time of the snapshot, the statement had an open cursor and was waiting for the client to resume fetching rows.

Using MON$STATEMENTS to Cancel a Query

Monitoring tables are read-only. However, the server has a built-in mechanism for deleting (and only deleting) records in the MON$STATEMENTS table, which makes it possible to cancel a running query.

[Note] Notes
  • If no statements are currently being executed in the connection, any attempt to cancel queries will not proceed
  • After a query is cancelled, calling execute/fetch API functions will return an error with the isc_cancelled code
  • Subsequent queries from this connection will proceed as normal

Example:  Cancelling all active queries for the specified connection:

DELETE FROM MON$STATEMENTS
  WHERE MON$ATTACHMENT_ID = 32
          

Prev: MON$RECORD_STATSFirebird 2.5 Language ReferenceUp: Monitoring TablesNext: MON$TRANSACTIONS
Firebird 2.5 Language ReferenceFirebird 2.5 Language ReferenceMonitoring Tables → MON$STATEMENTS