Page 1 of 1

Triggers capabilities to abort transactions

PostPosted: Sun Sep 01, 2013 11:23 am
by perencia
Hi,

as i saw in the source code, there's no possibility for a trigger to rollback and abort the transaction, am i correct ?

I wouldn't mind to implement that and submit a patch but I suppose that is a feature that requires some thought... are there any plans to support it ?

By the way, great work :)

Re: Triggers capabilities to abort transactions

PostPosted: Mon Sep 02, 2013 7:50 am
by qxorm
Hi,

In a trigger, you have the parameter : qx::dao::detail::IxDao_Helper * dao.
This parameter is useful for 2 things :
1- get the current connection (if you want to commit/rollback this is important) : dao->database() ;
2- and if an error occured in the trigger, you can write : dao->updateError(myError) (and this error will be returned to the caller).

Then, when you want to use transactions (commit/rollback), there is the class qx::QxSession :
- more details about this class in the FAQ here : http://www.qxorm.com/qxorm_en/faq.html#faq_170 ;
- and the class documentation : http://www.qxorm.com/doxygen/html/class ... ssion.html

Another possibility could be to throw an exception in your trigger using the class : qx::dao::sql_error.