Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 6934)
+++ trunk/MagicSoft/Mars/Changelog	(revision 6935)
@@ -21,4 +21,15 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2005/04/13 Daniela Dorner
+
+   * datacenter/macros/fillcalib.C:
+     - added update
+   
+   * datacenter/scripts/copyscript
+     - fixed bug
+
+
+
  2005/04/12 Daniela Dorner
 
Index: trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C	(revision 6934)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C	(revision 6935)
@@ -63,4 +63,5 @@
 #include <TFile.h>
 #include <TSQLResult.h>
+#include <TSQLRow.h>
 
 #include "MSQLServer.h"
@@ -70,4 +71,33 @@
 
 using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Checks whether an entry is already existing
+//
+Bool_t ExistStr(MSQLServer &serv, const char *column, const char *table, Int_t test)
+{
+    TString query(Form("SELECT %s FROM %s WHERE %s='%d'", column, table, column, test));
+    TSQLResult *res = serv.Query(query);
+    if (!res)
+        return kFALSE;
+
+    TSQLRow *row;
+
+    Bool_t rc = kFALSE;
+    while ((row=res->Next()))
+    {
+        if ((*row)[0])
+        {
+            rc = kTRUE;
+            break;
+        }
+    }
+
+    delete res;
+
+    return rc;
+}
+
 
 int Process(MSQLServer &serv, TString fname, Bool_t dummy)
@@ -125,19 +155,37 @@
     cout << "  Max.Cluster: (i/o)  " << Form("%3d", (int)clumax) << endl;                 // Max Cluster
 
+    TString query;
+    if (!ExistStr(serv, "fSequenceFirst", "MyMagic.Calibration", seq))
+    {
+
+        query = Form("INSERT MyMagic.Calibration SET"
+                     " fSequenceFirst=%d,"
+                     " fUnsuitableInner=%d, "
+                     " fUnsuitableOuter=%d, "
+                     " fUnreliableInner=%d, "
+                     " fUnreliableOuter=%d, "
+                     " fIsolatedInner=%d, "
+                     " fIsolatedOuter=%d, "
+                     " fIsolatedMaxCluster=%d",
+                     seq, (int)unsin, (int)unsout, (int)unrin,
+                     (int)unrout, (int)isoin, (int)isoout, (int)clumax);
+    }
+    else
+    {
+        query = Form("UPDATE MyMagic.Calibration SET"
+                     " fUnsuitableInner=%d, "
+                     " fUnsuitableOuter=%d, "
+                     " fUnreliableInner=%d, "
+                     " fUnreliableOuter=%d, "
+                     " fIsolatedInner=%d, "
+                     " fIsolatedOuter=%d, "
+                     " fIsolatedMaxCluster=%d"
+                     " WHERE fSequenceFirst=%d,",
+                     (int)unsin, (int)unsout, (int)unrin,(int)unrout,
+                     (int)isoin, (int)isoout, (int)clumax, seq);
+    }
+
     if (dummy)
         return 0;
-
-    TString query = Form("INSERT MyMagic.Calibration SET"
-                         " fSequenceFirst=%d,"
-                         " fUnsuitableInner=%d, "
-                         " fUnsuitableOuter=%d, "
-                         " fUnreliableInner=%d, "
-                         " fUnreliableOuter=%d, "
-                         " fIsolatedInner=%d, "
-                         " fIsolatedOuter=%d, "
-                         " fIsolatedMaxCluster=%d",
-                         seq, (int)unsin, (int)unsout, (int)unrin,
-                         (int)unrout, (int)isoin, (int)isoout, (int)clumax);
-
 
     TSQLResult *res = serv.Query(query);
@@ -147,4 +195,5 @@
         return 0;
     }
+    delete res;
 
     return 1;
Index: trunk/MagicSoft/Mars/datacenter/scripts/copyscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 6934)
+++ trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 6935)
@@ -226,5 +226,5 @@
          then
             #add file to donelist
-            echo "$filename processed" >> $transdir/.processed
+            echo "$file processed" >> $transdir/.processed
             echo $filename" moved and added to .processed" >> $scriptlog 2>&1 
          else
