All database operations in your controllers which are executed through DAL 
are executed in a transaction. 
So every time you do a database operation in your controller it starts a 
new transaction which is automatically commited if there were no errors. If 
it encounters any error then the transaction is rolled back. 

If you still want to control your transactions (e.g. if you wish to have 
more transaction in a single controller call) you can do it through 
db.commit() and db.rollback(). 

Take a look at this: 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=transaction#commit-and-rollback

On Monday, May 12, 2014 2:34:00 AM UTC+2, Xiaojian Huang wrote:
>
> I want to insert records into two tables A  and B. I will insert into A 
> first then B.
>
> and I like to rollback A when inserting into B failed. Is there any way to 
> do this?
>
> Thanks!
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to