Forum: Ruby triggering rollback manually-what methods should i use???

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2009-01-08 04:19
(Received via mailing list)
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
<model>.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
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2009-01-08 07:18
> 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
This topic is locked and can not be replied to.