triggering rollback manually-what methods should i use???

G

Greg Hauptmann

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


Hello andrea,
I was trying to code the classic tictactoe in ruby.
Now it only plays itself doing random moves until someone wins, and
there
are still some bugs.

But the thing that really I don't understand is another,

With this line every time I pick the next move:

x, y = (0...(board.length)).to_a.choice, (0...
(board.length)).to_a.choice

But I get always the same game!!:

[snip]

You should add a call to srand before the call to random_play. It
will seed the random number generator so that you don't get the
same sequence of random numbers every time you run your program.
 
R

Roger Pack

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top