# Triggering rollback manually-what methods should i use?

**URL:** <https://www.ruby-forum.com/t/triggering-rollback-manually-what-methods-should-i-use/157173>\
**Category:** Ruby\
**Created:** [January 8, 2009, 4:19am UTC](https://www.ruby-forum.com/t/triggering-rollback-manually-what-methods-should-i-use/157173 "2009-01-08T04:19:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [January 8, 2009, 4:19am UTC](https://www.ruby-forum.com/t/triggering-rollback-manually-what-methods-should-i-use/157173/1 "2009-01-08T04:19:35Z")

</div>

hi

Q1. If I want to manually trigger a DB transaction roleback  
progrmatically what approach/methods should I use?

Q2. Also if in the transactions I use multiple models, should I start  
the transaction by (a) choosing one of the models & going  
.transaction do, or (b) use some other generic DB transaction  
method (ie no model namc)?

REQUIREMENTS:

- upload of records from file
- want to try each one re loading into DB, then collect errors in  
array for those that fail
- then at end want to:  
(a) roll back everything , but also  
(b) overall method should NOT raise exception (ie why I want to  
trigger rollback without relying on an exception to do this

thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [January 8, 2009, 7:18am UTC](https://www.ruby-forum.com/t/triggering-rollback-manually-what-methods-should-i-use/157173/2 "2009-01-08T07:18:13Z")

</div>

> Q1. If I want to manually trigger a DB transaction roleback  
> progrmatically what approach/methods should I use?

If it’s straight mysql it’s something like  
execute(“BEGIN”)  
execute(“ROLLBACK”)

If it’s rails then I know raising causes one, not sure of others.  
Cheers!  
-=r  
google rails how to rollback without raise
