Posted to tcl by kbk at Fri May 14 19:48:15 GMT 2010view raw

  1. # The 'transaction' method executes a block of Tcl code as an
  2. # ACID transaction against the database.
  3.  
  4. method transaction {script} {
  5. my begintransaction
  6. set status [catch {uplevel 1 $script} result options]
  7. switch -exact -- $status {
  8. 0 {
  9. my commit
  10. }
  11. 2 - 3 - 4 {
  12. set options [dict merge {-level 1} $options[set options {}]]
  13. dict incr options -level
  14. my commit
  15. }
  16. default {
  17. my rollback
  18. }
  19. }
  20. return -options $options $result
  21. }