aboutsummaryrefslogtreecommitdiff
path: root/libBasicTableOperations.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'libBasicTableOperations.tcl')
-rwxr-xr-xlibBasicTableOperations.tcl37
1 files changed, 27 insertions, 10 deletions
diff --git a/libBasicTableOperations.tcl b/libBasicTableOperations.tcl
index 70b8dab..ff52f31 100755
--- a/libBasicTableOperations.tcl
+++ b/libBasicTableOperations.tcl
@@ -111,8 +111,10 @@ proc DeleteColumnFromTable { table columnname } {
}
set beginTransactionCounter 0
-proc begin_db_transaction { } {
+proc begin_db_transaction { {do_not_begin {false}} } {
+ # do_not_begin intended for restoring transaction state asseses previously
global beginTransactionCounter
+ if { $do_not_begin } { return }
incr beginTransactionCounter
if { $beginTransactionCounter == 1 } {
# starting transaction
@@ -125,17 +127,32 @@ proc begin_db_transaction { } {
}
}
-proc end_db_transaction { } {
+proc getTransactionState { } {
global beginTransactionCounter
+ if { $beginTransactionCounter >= 1 } {
+ return true
+ }
+ return false
+}
+
+
+
+proc end_db_transaction { {force_end {false}} } {
+ # force_end == true ends all transactions
+ global beginTransactionCounter
+ if { $force_end && ( $beginTransactionCounter >= 1) } {
+ set beginTransactionCounter 1
+ }
incr beginTransactionCounter -1
- if { $beginTransactionCounter > 0 } return;
- # closing transaction
- set eval_str [concat END TRANSACTION]
- set err [catch {db eval $eval_str } errStat]
- if { $err } {
- htmlErrorMsg $errStat end_db_transaction
- dbg "the following error happen: $errStat" msg_level_critical begin_db_transaction
- }
+ if { ($beginTransactionCounter == 0) } {
+ # closing transaction
+ set eval_str [concat END TRANSACTION]
+ set err [catch {db eval $eval_str } errStat]
+ if { $err } {
+ htmlErrorMsg $errStat end_db_transaction
+ dbg "the following error happen: $errStat" msg_level_critical begin_db_transaction
+}
+ }
}