E.8MON$STATEMENTS

MON$STATEMENTS displays statements prepared for execution.

Column NameData TypeDescription

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.

E.8.1Using 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.

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

ExampleCancelling all active queries for the specified connection:

  |DELETE FROM MON$STATEMENTS
  |  WHERE MON$ATTACHMENT_ID = 32