Index: trunk/MagicSoft/Mars/msql/MSQLMagic.cc
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9001)
+++ trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9039)
@@ -195,5 +195,8 @@
 Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test, const char *where)
 {
-    TString query(Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:""));
+    TString query = test ?
+        Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:"") :
+        Form("SELECT %s FROM %s WHERE %s", column, table, where);
+
     TSQLResult *res = Query(query);
     if (!res)
@@ -211,4 +214,14 @@
     delete res;
     return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if at least one row with one field exists in table
+// defined by where
+//
+Bool_t MSQLMagic::ExistRow(const char *table, const char *where)
+{
+    return ExistStr("*", table, 0, where);
 }
 
@@ -306,4 +319,17 @@
 // --------------------------------------------------------------------------
 //
+// An abbreviation for checking whether a row with the condition where
+// exists. If no such row exist Insert vars into table, otherwise update
+// vars in table at row(s) defined by where.
+//
+Int_t MSQLMagic::InsertUpdate(const char *table, const char *vars, const char *where)
+{
+    return ExistRow(table, where) ?
+        Update(table, vars, where) :
+        Insert(table, vars);
+}
+
+// --------------------------------------------------------------------------
+//
 // An abbreviation for a Dalete-Query.
 //
Index: trunk/MagicSoft/Mars/msql/MSQLMagic.h
===================================================================
--- trunk/MagicSoft/Mars/msql/MSQLMagic.h	(revision 9001)
+++ trunk/MagicSoft/Mars/msql/MSQLMagic.h	(revision 9039)
@@ -45,4 +45,5 @@
     Int_t   QueryKeyOf(const char *col, const char *ext, const char *val);
     Bool_t  ExistStr(const char *column, const char *table, const char *test, const char *where=0);
+    Bool_t  ExistRow(const char *table, const char *where);
 
     Int_t Insert(const char *table, const char *vars, const char *where=0);
@@ -50,4 +51,5 @@
     Int_t Delete(const char *table, const char *where);
     Int_t InsertUpdate(const char *table, const char *col, const char *val, const char *vars);
+    Int_t InsertUpdate(const char *table, const char *vars, const char *where);
 
     void Delete(const Option_t *o) { TObject::Delete(o); }
