Subject Re: [firebird-support] Re: FB 2.1 - new DB trigger feature with MON$ tables
Author Dmitry Yemanov
Paul R. Gardner wrote:
>
> CREATE TRIGGER DATALOGGER
> ACTIVE ON TRANSACTION COMMIT POSITION 0
> AS
> BEGIN
> INSERT INTO GOODSQL(SQLTIME, SQLCMD)
> SELECT CURRENT_TIMESTAMP, M.MON$SQL_TEXT
> FROM MON$STATEMENTS M
> WHERE M.MON$TRANSACTION_ID = CURRENT_TRANSACTION;
> END
>
> This never inserts anything either. When I view the MON$STATEMENTS
> table before my application commits or does a rollback, I can see the
> SQL in question. The TRANSACTION_ID field is always null. It's null
> for all statements listed EXCEPT the one that IBExpert generated to view
> that table (select * from MON$STATEMENTS).

This is more or less as designed. Statement's MON$TRANSACTION_ID is not
null only when the statement is active (i.e. running or being fetched
from). As soon as the statement execution is terminated (e.g. upon
exception), it's no longer bound to a particular transaction.


Dmitry