-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/27/2010 06:37 PM, BareFeetWare wrote:
> 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". 

What programming language are you using?

For Python we use exceptions which makes doing the above really easy.
Rather than checking error codes, exceptions are thrown.  Calling code
catches the exception and rolls back.

  execute("BEGIN")
  try:
     execute(... whatever ...)
     execute("COMMIT")
  except:
     execute("ROLLBACK")

If you are using a language without exceptions then you may be able to
emulate something like that through macros or other mechanisms.

BTW the above is a little verbose for explanatory purposes.  In Python you'd
actually reduce it to two lines which does all of the above behind the scenes:

  with connection:
    connection.execute(... whatever ...)

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0ZlVMACgkQmOOfHg372QSnYQCfUKEmiN+ZWW/DldLPz3/6dC09
i0kAnitUR5tdt80ZhsGiUzzmyTlkRuis
=YDpz
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to