Subject Re: [firebird-support] Fwd: Firebird MON$STATEMENTS table MON$TRANSACTION_ID field [null]
Author Mark Rotteveel
On 26-3-2015 14:33, Resul Demirok resul.demirok@...
[firebird-support] wrote:
> I have try to get sql text from active transaction. I had got some sql
> text but some sql text is empty. I searched reason and i undertastand
> mon$statements table mon$transaction_id is null and some transaction has
> id in this table but as has null. why transactions id cannot add to this
> table?

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.

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.

Also: sql text can be null/empty if the statement handle has been
created, but hasn't yet been prepared with a statement. I also believe
that for DDL statements the statement is automatically unprepared after
execute (and the statement handle can then be reused).

Mark Rotteveel