Weird transaction problem

I dont want the row to be created in the DB if there is any error even
after the save. So what should be done??
The below is the log:
SQL (0.001000) INSERT INTO projects ('name', 'user_id')
VALUES('test', 10)
   app/models/project.rb:305:in `confirm_project'
   app/models/project.rb:288:in `confirm_project'
   app/models/project.rb:274:in `confirm_project'
   app/controllers/test_controller.rb:19:in `confirm_project'
   app/controllers/test_controller.rb:12:in `select_user'
SQL (0.000000) ROLLBACK

That's normal. Were you expecting to see DELETE FROM projects ... ?

Fred

Hi Fred,
Yes I am expecting to see DELETE FROM projects..
Is it not possible in the transaction block??

Frederick Cheung wrote:

Hi Fred,
Yes I am expecting to see DELETE FROM projects..
Is it not possible in the transaction block??

That's just not how transactions work. The ROLLBACK statement does the
work of unwinding all the changes since the previous BEGIN.

Fred

I'm a little out of date here. Does MySQL support nested transactions,
and if it does, does AR support it?

That's just not how transactions work. The ROLLBACK statement does
the
work of unwinding all the changes since the previous BEGIN.

I'm a little out of date here. Does MySQL support nested transactions,
and if it does, does AR support it?

Mysql 5 has savepoints. AR doesn't do anything with them.

Fred

But a roll back should come to the previous state. so in this case how i
can get back to the previous state with out inserting into DB..
What should I do??

Frederick Cheung wrote:

But a roll back should come to the previous state. so in this case
how i
can get back to the previous state with out inserting into DB..
What should I do??

The ROLLBACK statement magically unwinds all changes made. The
database (ie not your app or activerecord) takes care of that.

Hi,
  Thanks a lot. Now its working fine. Right now my table type is MyISAM
and I changed the type into InnoDB Storage. In this type the
transactions are safe.
Now all the transactions are getting rolled back.

Frederick Cheung wrote:

Hi,
Thanks a lot. Now its working fine. Right now my table type is MyISAM
and I changed the type into InnoDB Storage. In this type the
transactions are safe.
Now all the transactions are getting rolled back.

Ah yes. As you have found out, myisam doesn't do transactions at all

Fred