On 23/12/2010, at 5:59 PM, Max Vlasov wrote:

> On Thu, Dec 23, 2010 at 9:52 AM, BareFeetWare 
> <list....@barefeetware.com>wrote:
> 
>> I want to be able to just send a series of SQL commands in a transaction as 
>> one block... and have SQLite tell me either that it succeeded so committed, 
>> or that it failed so everything has been rolled back. It is my understanding 
>> that this is one of the primary purposes of transactions. In this way, I can 
>> already string together a series of inserts, updates and deletes and execute 
>> as one block in a transaction, I'd like to be able to do the same with other 
>> SQL commands (eg drop and create).
> 
> Tom, I think that the idea is to move only first (begin) and last 
> (commit/rollback) from you queries. In this case your queries can still 
> contain other queries like drop and create. You just have to check for error 
> in step command and, analyze sqlite3_get_autocommit() and do rollback 
> optionally (or do it anyway with a error being not error). Anyway, I think 
> that getting rid of transaction commands make you queries more portable since 
> you will be able to concatenate them before wrapping into begin/end

Thanks for the reply, but you're kind of restating the problem.

Yes, I know that in my application code I can step through each command in the 
transaction, check for an error, and if there is an error, end the transaction 
with a "rollback" instead of a "commit". But I want to avoid having to check 
the result of each command in application code. I want the SQL to take care of 
the commit/rollback decision so I can just give SQLite a transaction block that 
will work as a whole or else just rollback and have no effect. Then I can send 
that SQL transaction block via whatever SQLite front end (eg the sqlite3 
command line) I like, so it's portable.

This works for transactions containing insert, update and delete, but not for 
create and drop commands, which seems inconsistent to me. If I put these 
commands inside a transaction, surely I want to have the transaction rollback 
if anything fails within it.

Thanks,
Tom
BareFeetWare

 --
Comparison of SQLite GUI tools:
http://www.barefeetware.com/sqlite/compare/?ml

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to