From: Brian Candler Date: 2003-06-08T16:38:20+09:00 Subject: Re: [ANN] sql-serialize 0.0.3 On Sun, Jun 08, 2003 at 03:13:56PM +0900, Anders Borch wrote: > snippet from my code: > > def insert (dbi) > begin > dbi.do("BEGIN") > sql_insert (dbi) > sql_insert_array (dbi) > sql_insert_hash (dbi) > sql_insert_assoc (dbi) > dbi.do("COMMIT") Or you could write: dbi.transaction do sql_insert(dbi) ... end (which might in future work better; beware that right now ruby-dbi has no concept of "begin transaction" so it's rather broken in this regard) > rescue DBI::DatabaseError => dbe > dbi.do("ROLLBACK") > throw dbe > end Are you sure that's right??? I think you want to do a rollback for *all* exceptions. That's one reason why the 'transaction do ... end' model might be better. Regards, Brian.