26.03.2015 21:49, Mark Rotteveel wrote: > The MON$STATEMENTS contains the statement handles in Firebird. The > lifetime of a statement handle is separate from the transaction. > Therefor if there is currently no transaction associated with the > statement (eg: the statement handle has been created but not yet > prepared or executed), then the transaction id is null.
Almost correct. MON$STATEMENTS enlists only prepared statement handles, it does not include allocated handles that are not prepared yet. > Also if a statement has been executed with a transaction, it will be > disassociated once the transaction has been committed or rolled back. I > am not entirely sure, but I believe the transaction is also > disassociated if the statement has completed (update, delete, etc), or - > for select - the cursor has been explicitly closed/dropped or if all > records have been read. Statement is linked to a transaction when it starts its execution, and unlinked from a transaction when it completes. It also implies that even prepared but currently inactive (not yet executed) statement is not linked to any transaction. Although the prepare call requires a transaction handle, it does not cause any "linkage" between them. Dmitry