Index: trunk/ippToPsps/src/Dvo.c
===================================================================
--- trunk/ippToPsps/src/Dvo.c	(revision 31931)
+++ trunk/ippToPsps/src/Dvo.c	(revision 31965)
@@ -35,5 +35,5 @@
     mysql_query(this->mysql, "DELETE FROM dvoDetection");
 
-    mysql_query(this->mysql, "SELECT sourceID, imageID FROM dvoMeta");
+    mysql_query(this->mysql, "SELECT sourceID, externID FROM dvoMeta");
     MYSQL_RES* result = mysql_store_result(this->mysql);
 
@@ -41,19 +41,19 @@
     MYSQL_ROW row;
     char sql[500];
-    int sourceID, imageID;
+    int sourceID, externID;
     while ((row = mysql_fetch_row(result))) {
 
         sourceID = atoi(row[0]);
-        imageID = atoi(row[1]);
+        externID = atoi(row[1]);
 
         this->logger->print(this->logger, MSG_INFO, "Dvo", "---------------------------------------------------------------------\n");
-        this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting skylist from DVO database for source ID = %d and image ID = %d\n",
-                sourceID, imageID); 
-        skyList = dvoSkyListByExternID(this->dvoConfig, sourceID, imageID, &image);
+        this->logger->print(this->logger, MSG_INFO, "Dvo", "Getting skylist from DVO database for source ID = %d and extern ID = %d\n",
+                sourceID, externID); 
+        skyList = dvoSkyListByExternID(this->dvoConfig, sourceID, externID, &image);
         if (!skyList) {
 
             this->logger->print(this->logger, MSG_ERROR, 
-                    "Dvo", "Could not find skylist for sourceId=%d and image ID = %d\n", 
-                    sourceID, imageID);
+                    "Dvo", "Could not find skylist for sourceId=%d and extern ID = %d\n", 
+                    sourceID, externID);
 
             continue;
@@ -61,9 +61,10 @@
 
         sprintf(sql, 
-                "UPDATE dvoMeta SET flags = %d, photcode = %d WHERE sourceID = %d AND imageID = %d",
+                "UPDATE dvoMeta SET imageID = %d,flags = %d, photcode = %d WHERE sourceID = %d AND externID = %d",
+                image->imageID,
                 image->flags,
                 image->photcode,
                 sourceID,
-                imageID);
+                externID);
         mysql_query(this->mysql, sql); 
 
@@ -92,5 +93,5 @@
                         "INSERT INTO dvoDetection (sourceID, imageID, ippDetectID, detectID, ippObjID, objID, flags) VALUES (%d, %d, %u, %lu, %lu, %lu, %u)",
                         sourceID,   // sourceID
-                        imageID,    // imageID
+                        image->imageID,    // imageID
                         dvoDetections[i].meas.detID,   // ippDetectID
                         dvoDetections[i].meas.extID,   // detectID
