RE: [sqlite] Does Transaction object roll back automatically on exceptions?
Note that by default the ADO.NET wrapper executes transactions in immediate mode which is not desirable for read-only data. To start a deferred transaction, you need to use the SQLite.NET-specific overload BeginTransaction(true) which is not available if using the DbProvider object model. Best regards, Sam --- We're Hiring! Seeking a passionate developer to join our team building products. Position is in the Washington D.C. metro area. If interested contact [EMAIL PROTECTED] -Original Message- From: Ahmed Sulaiman [mailto:[EMAIL PROTECTED] Sent: Monday, July 16, 2007 4:47 PM To: sqlite-users@sqlite.org Subject: RE: [sqlite] Does Transaction object roll back automatically on exceptions? Hi all, Is it necessary to run a "SELECT" command in between a transaction? I have few places in my code where I have a command that reads some data from a table, and I wonder if I should begin/commit a transaction? Is there any performance issues if I did or didn't do that? Regards - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] Does Transaction object roll back automatically on exceptions?
On Mon, 2007-07-16 at 16:47 -0400, Ahmed Sulaiman wrote: > Hi all, > > Is it necessary to run a "SELECT" command in between a transaction? I > have few places in my code where I have a command that reads some data > from a table, and I wonder if I should begin/commit a transaction? Is > there any performance issues if I did or didn't do that? It's not necessary, and unlikely to have a noticeable effect on performance. This decision should be made based on the logical requirements of the system (i.e. is it important that SQL statements executed after the SELECT operate on a consistent snapshot of the database). Dan. > Regards > > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] Does Transaction object roll back automatically on exceptions?
Hi all, Is it necessary to run a "SELECT" command in between a transaction? I have few places in my code where I have a command that reads some data from a table, and I wonder if I should begin/commit a transaction? Is there any performance issues if I did or didn't do that? Regards - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] Does Transaction object roll back automatically on exceptions?
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Monday, July 16, 2007 9:14 AM > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] Does Transaction object roll back > automatically on exceptions? > > "Ahmed Sulaiman" <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I have tried this question in the forum with no answer, so > I decide to > > give it a try here :) > > > > I am using the "Using" statements in C# to handle the > closing of SQLite > > connection, transaction and command objects. I have this setup in > > different places in my code (Generic methods returning > SQLite objects) > > > > using (IDbConnection conn = CreateConnection()) > > { > >conn.Open(); > >using (IDbTransaction transaction = conn.BeginTransaction()) > > { > > Dosomething(); > > transaction.Commit(); > > } > >} > > > > My question, what happens if there was an exception inside the > > transaction using block? I know that the transaction object would be > > closed and disposed, but does the traction roll back > automatically by > > the SQLite engine, or do I need to have special logic for > that? What is > > the suggested best practices in this case? > > > > In the equivalent code in TCL, the transaction would > rollback automatically. But I do not know anything > about the C# bindings that you are using, so I do not > know what will happen in your case. Have you tried it > to see? What does the documentation that comes with > your SQLite C# bindings say? It is the C# bindings, > not the SQLite core, that will determine this behavior. Answered on the SQLite.NET forums. The ADO.NET wrapper automatically roll back as well. Robert - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] Does Transaction object roll back automatically on exceptions?
Thanks for the reply. I have got the code for the binding and it actually does roll back automatically in case of exceptions. :) Ahmed -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 16, 2007 12:14 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Does Transaction object roll back automatically on exceptions? "Ahmed Sulaiman" <[EMAIL PROTECTED]> wrote: > Hi all, > > I have tried this question in the forum with no answer, so I decide to > give it a try here :) > > I am using the "Using" statements in C# to handle the closing of SQLite > connection, transaction and command objects. I have this setup in > different places in my code (Generic methods returning SQLite objects) > > using (IDbConnection conn = CreateConnection()) > { >conn.Open(); >using (IDbTransaction transaction = conn.BeginTransaction()) > { > Dosomething(); > transaction.Commit(); > } >} > > My question, what happens if there was an exception inside the > transaction using block? I know that the transaction object would be > closed and disposed, but does the traction roll back automatically by > the SQLite engine, or do I need to have special logic for that? What is > the suggested best practices in this case? > In the equivalent code in TCL, the transaction would rollback automatically. But I do not know anything about the C# bindings that you are using, so I do not know what will happen in your case. Have you tried it to see? What does the documentation that comes with your SQLite C# bindings say? It is the C# bindings, not the SQLite core, that will determine this behavior. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] Does Transaction object roll back automatically on exceptions?
Rollback is automatic if no Commit is issued in SQLite.NET. If you want custom logic, such as including additional exception information, then use try/catch BeginTransaction(); try { .. Commit(); } catch(Exception ex) { RollBack(); throw new Exception("An exception occurred and the transaction has been rolled back.", ex); } HTH, Sam --- We're Hiring! Seeking a passionate developer to join our team building products. Position is in the Washington D.C. metro area. If interested contact [EMAIL PROTECTED] -Original Message- From: Ahmed Sulaiman [mailto:[EMAIL PROTECTED] Sent: Monday, July 16, 2007 10:52 AM To: sqlite-users@sqlite.org Subject: [sqlite] Does Transaction object roll back automatically on exceptions? Hi all, I have tried this question in the forum with no answer, so I decide to give it a try here :) I am using the "Using" statements in C# to handle the closing of SQLite connection, transaction and command objects. I have this setup in different places in my code (Generic methods returning SQLite objects) using (IDbConnection conn = CreateConnection()) { conn.Open(); using (IDbTransaction transaction = conn.BeginTransaction()) { Dosomething(); transaction.Commit(); } } My question, what happens if there was an exception inside the transaction using block? I know that the transaction object would be closed and disposed, but does the traction roll back automatically by the SQLite engine, or do I need to have special logic for that? What is the suggested best practices in this case? Cheers - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Does Transaction object roll back automatically on exceptions?
"Ahmed Sulaiman" <[EMAIL PROTECTED]> wrote: > Hi all, > > I have tried this question in the forum with no answer, so I decide to > give it a try here :) > > I am using the "Using" statements in C# to handle the closing of SQLite > connection, transaction and command objects. I have this setup in > different places in my code (Generic methods returning SQLite objects) > > using (IDbConnection conn = CreateConnection()) > { >conn.Open(); >using (IDbTransaction transaction = conn.BeginTransaction()) > { > Dosomething(); > transaction.Commit(); > } >} > > My question, what happens if there was an exception inside the > transaction using block? I know that the transaction object would be > closed and disposed, but does the traction roll back automatically by > the SQLite engine, or do I need to have special logic for that? What is > the suggested best practices in this case? > In the equivalent code in TCL, the transaction would rollback automatically. But I do not know anything about the C# bindings that you are using, so I do not know what will happen in your case. Have you tried it to see? What does the documentation that comes with your SQLite C# bindings say? It is the C# bindings, not the SQLite core, that will determine this behavior. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -