Wilfried Mestdagh <[EMAIL PROTECTED]>
wrote:
Do I need the 'begin transaction' and 'commit' ? It seems it works
without them also. I'm not sure I fully understeand wy I need them. If
someone can explain in simple English ?
If you don't explicitly start a transaction, an implicit begin and
commit happens around every SQL statement you execute. Often, this is
just fine, but there are a few situations when you want an explicit
transaction.
E.g. there are times when you need several SQL statements to execute
atomically (that is, all changes occur or no changes occur - a failure
in the middle of an operation might leave the DB in an inconsistent
state). The classic example is a transfer between two bank accounts -
you want to debit one and credit the other atomically, you definitely
don't want to end up in a situation where one was debited but the other
was never credited, or vice versa.
There is another reason that is more or less specific to SQLite: a batch
of data manipulation (insert, update and delete) statements completes
much faster when all statements are executed under a single transaction.
I understeand that if I use them, and some serious error occures then
there is a rollback so that my application can know the place where is
not updated , but do I need it for a simple insert or update of 1
record ?
An implicit transaction is sufficient for this case.
Igor Tandetnik