Page 1 of 1

Two questions about triggers

PostPosted: Tue Feb 26, 2013 9:26 am
by remico
Hello.
1) Is it possible to get the OLD value and the NEW value simultaneously into "update" triggers (like into natural triggers of any DBMS)?
And if no way to do this, how to make the right something like a "cascading update of a non-foreign-key field into a table according to an updated field into another table"?
2) Is it correct to open and use transactions into triggers or it is more correct to open transactions before invoking qx::dao::* functions?
Thanks in advance.

Re: Two questions about triggers

PostPosted: Tue Feb 26, 2013 3:18 pm
by qxorm
Hi,

1) Is it possible to get the OLD value and the NEW value simultaneously into "update" triggers (like into natural triggers of any DBMS)?
And if no way to do this, how to make the right something like a "cascading update of a non-foreign-key field into a table according to an updated field into another table"?

Yes you can have old and new values using qx::dao::ptr<T> smart pointer.
Here is a FAQ about qx::dao::ptr<T> smart pointer : http://www.qxorm.com/qxorm_en/faq.html#faq_81
And here is the documentation : http://www.qxorm.com/doxygen/html/class ... _1ptr.html

2) Is it correct to open and use transactions into triggers or it is more correct to open transactions before invoking qx::dao::* functions?

I think you should always open a transaction before using qx::dao::* functions.
For transactions, you can also use session concept : http://www.qxorm.com/qxorm_en/faq.html#faq_170