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

# The 'transaction' method executes a block of Tcl code as an
    # ACID transaction against the database.

    method transaction {script} {
	my begintransaction
	set status [catch {uplevel 1 $script} result options]
	switch -exact -- $status {
	    0 {
		my commit
	    }
	    2 - 3 - 4 {
		set options [dict merge {-level 1} $options[set options {}]]
		dict incr options -level
		my commit
	    }
	    default {
		my rollback
	    }
	}
	return -options $options $result
    }