Index: trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C	(revision 7182)
+++ trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C	(revision 7183)
@@ -335,5 +335,5 @@
 Bool_t NewSequence(MSQLServer &serv, Int_t from, Int_t to, Int_t src, Bool_t dummy)
 {
-    cout << "Found Sequence (" << from << ", " << to << ") ... checking..." << flush;
+    cout << "Found Sequence (" << from << ", " << to << ") ... checking runs..." << flush;
 
     if (!CheckSequence(serv, from, to, src, 2))
@@ -442,5 +442,5 @@
                     MTime *tm = new MTime;
                     tm->SetSqlDateTime((*row)[2]);
-                    map.Add((ULong_t)map.GetSize(), (Long_t)nblocks, (Long_t)tm);
+                    map.Add((ULong_t)map.GetSize(), (Long_t)tm, (Long_t)nblocks);
                 }
             }
@@ -451,5 +451,5 @@
             {
                 MTime *tm = new MTime(lasttime);
-                map.Add((ULong_t)map.GetSize(), (Long_t)nblocks, (Long_t)tm);
+                map.Add((ULong_t)map.GetSize(), (Long_t)tm, (Long_t)nblocks);
 
                 stop = last;
@@ -505,10 +505,10 @@
         while (nmap.Next(key, val))
         {
-            MTime *t = (MTime*)val;
+            MTime *t = (MTime*)key;
 
             if (nmin==-1)
             {
-                nmin = key;
-                min  = *(MTime*)val;
+                nmin = val;
+                min  = *(MTime*)key;
                 dmin = fabs((Double_t)*t-(Double_t)tstart);
             }
@@ -516,5 +516,5 @@
             if (fabs((Double_t)*t-(Double_t)tstart) < dmin)
             {
-                nmin = key;
+                nmin = val;
                 dmin = fabs((Double_t)*t-(Double_t)tstart);
                 min = *t;
@@ -522,5 +522,5 @@
             if (fabs((Double_t)*t-(Double_t)tstop) < dmin)
             {
-                nmin = key;
+                nmin = val;
                 dmin = fabs((Double_t)*t-(Double_t)tstop);
                 min = *t;
@@ -596,2 +596,31 @@
     return rc ? 1 : 0;
 }
+
+int buildsequenceentries()
+{
+    TEnv env("sql.rc");
+
+    MSQLServer serv(env);
+    if (!serv.IsConnected())
+    {
+        cout << "ERROR - Connection to database failed." << endl;
+        return 0;
+    }
+
+    TString query="SELECT fDate FROM SequenceBuildStatus";
+
+    cout << "Q: " << query << endl;
+
+    TSQLResult *res = serv.Query(query);
+    if (!res)
+        return 0;
+
+    TSQLRow *row=0;
+    while ((row=res->Next()))
+    {
+        cout << "date: " << (*row)[0] << endl;
+        buildsequenceentries((*row)[0]);
+    }
+
+    return 1;
+}
