changeset 37:c3c597cac4b6

Add helper function qdb_sql_exec for simplifying certain SQL operations.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 06 Sep 2011 18:21:32 +0300
parents b24cb1dd0423
children a825a4e27627
files quotedb.tcl
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/quotedb.tcl	Tue Sep 06 18:19:13 2011 +0300
+++ b/quotedb.tcl	Tue Sep 06 18:21:32 2011 +0300
@@ -142,6 +142,16 @@
   return [string map {' ''} $str]
 }
 
+proc qdb_sql_exec { upublic unick uchan usql } {
+  global quotedb
+  if {[catch {quotedb eval $usql} uerrmsg]} {
+    qdb_log "$uerrmsg on SQL:\n$usql"
+    qdb_msg $upublic $unick $uchan "virhe sörkittäessä tietokantaa. uliskaa."
+    return 0
+  }
+  return 1
+}
+
 
 #-------------------------------------------------------------------------
 proc qdb_add {utable utext uhand unick uhost uchan upublic} {