Index: trunk/ippTools/src/regtool.c
===================================================================
--- trunk/ippTools/src/regtool.c	(revision 9028)
+++ trunk/ippTools/src/regtool.c	(revision 9057)
@@ -72,14 +72,14 @@
         "SELECT newExp.*"
         "   FROM newExp"
-        " LEFT JOIN newImfile USING(exp_id)"
-        " LEFT JOIN rawScienceExp USING(exp_id)"
-        " LEFT JOIN rawDetrendExp USING(exp_id)"
+        " LEFT JOIN newImfile USING(exp_tag)"
+        " LEFT JOIN rawScienceExp USING(exp_tag)"
+        " LEFT JOIN rawDetrendExp USING(exp_tag)"
         " WHERE"
-        "   newExp.exp_id IS NOT NULL"
-        "   AND newImfile.exp_id IS NULL"
-        "   AND rawScienceExp.exp_id IS NULL"
+        "   newExp.exp_tag IS NOT NULL"
+        "   AND newImfile.exp_tag IS NULL"
+        "   AND rawScienceExp.exp_tag IS NULL"
         "   AND newExp.imfiles ="
-        "   (SELECT COUNT(exp_id) FROM rawImfile"
-        "       WHERE rawImfile.exp_id = newExp.exp_id)"
+        "   (SELECT COUNT(exp_tag) FROM rawImfile"
+        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
         ;
 
@@ -123,17 +123,17 @@
 
     // select newImfiles that:
-    // exp_id is in newExp
-    // don't have their exp_id in rawScienceExp 
-    // don't have their exp_id in rawDetrendExp
-    // XXX having the same exp_id in newExp and raw*Exp is probably an error
+    // exp_tag is in newExp
+    // don't have their exp_tag in rawScienceExp 
+    // don't have their exp_tag in rawDetrendExp
+    // XXX having the same exp_tag in newExp and raw*Exp is probably an error
     // that should be checked for
     char *query =
         "SELECT newImfile.* FROM newImfile"
-        " LEFT JOIN newExp USING(exp_id)"
-        " LEFT JOIN rawScienceExp USING(exp_id)"
-        " LEFT JOIN rawDetrendExp USING (exp_id)"
-        " WHERE newExp.exp_id is NOT NULL"
-        " AND rawScienceExp.exp_id IS NULL"
-        " AND rawDetrendExp.exp_id IS NULL";
+        " LEFT JOIN newExp USING(exp_tag)"
+        " LEFT JOIN rawScienceExp USING(exp_tag)"
+        " LEFT JOIN rawDetrendExp USING (exp_tag)"
+        " WHERE newExp.exp_tag is NOT NULL"
+        " AND rawScienceExp.exp_tag IS NULL"
+        " AND rawDetrendExp.exp_tag IS NULL";
 
     if (!p_psDBRunQuery(config->dbh, query)) {
@@ -175,8 +175,8 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // make sure that the exp_id(s) are ready to be updated based on:
-    // exp_id is not in rawScienceExp
-    // exp_id is not in rawDetrendExp
-    // exp_id is not in newImfile
+    // make sure that the exp_tag(s) are ready to be updated based on:
+    // exp_tag is not in rawScienceExp
+    // exp_tag is not in rawDetrendExp
+    // exp_tag is not in newImfile
     // that the correct count of imfiles is in rawImfile
 
@@ -184,26 +184,26 @@
         "SELECT newExp.*"
         "   FROM newExp"
-        " LEFT JOIN newImfile USING(exp_id)"
-        " LEFT JOIN rawScienceExp USING(exp_id)"
-        " LEFT JOIN rawDetrendExp USING(exp_id)"
+        " LEFT JOIN newImfile USING(exp_tag)"
+        " LEFT JOIN rawScienceExp USING(exp_tag)"
+        " LEFT JOIN rawDetrendExp USING(exp_tag)"
         " WHERE"
-        "   newExp.exp_id IS NOT NULL"
-        "   AND newImfile.exp_id IS NULL"
-        "   AND rawScienceExp.exp_id IS NULL"
+        "   newExp.exp_tag IS NOT NULL"
+        "   AND newImfile.exp_tag IS NULL"
+        "   AND rawScienceExp.exp_tag IS NULL"
         "   AND newExp.imfiles ="
-        "   (SELECT COUNT(exp_id) FROM rawImfile"
-        "       WHERE rawImfile.exp_id = newExp.exp_id)"
+        "   (SELECT COUNT(exp_tag) FROM rawImfile"
+        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
         );
 
     {        
         bool status = false;
-        psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+        psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
         if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
             psFree(query);
             return false;
         }
-        if (exp_id) {
-            psStringAppend(&query, " AND newExp.exp_id = '%s'", exp_id);
+        if (exp_tag) {
+            psStringAppend(&query, " AND newExp.exp_tag = '%s'", exp_tag);
         }
     }
@@ -359,12 +359,12 @@
         psArray *rawImfiles = NULL;
         {
-            // build a query to search by exp_id
+            // build a query to search by exp_tag
             psMetadata *where = psMetadataAlloc();
-            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", newExp->exp_id)) {
+            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", newExp->exp_tag)) {
                 // rollback
                 if (!psDBRollback(config->dbh)) {
                     psError(PS_ERR_UNKNOWN, false, "database error");
                 }
-                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
+                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
                 psFree(where);
                 psFree(newExp);
@@ -381,5 +381,5 @@
                 psError(PS_ERR_UNKNOWN, false, "database error");
             }
-            psError(PS_ERR_UNKNOWN, false, "found no rawImfiles associated with exp_id %s", newExp->exp_id);
+            psError(PS_ERR_UNKNOWN, false, "found no rawImfiles associated with exp_tag %s", newExp->exp_tag);
             psFree(newExp);
             psFree(output);
@@ -439,25 +439,25 @@
         "SELECT * FROM"
             " (SELECT newImfile.* FROM newImfile"
-                " LEFT JOIN newExp USING(exp_id)"
-                " LEFT JOIN rawScienceExp USING(exp_id)"
-                " LEFT JOIN rawDetrendExp USING (exp_id)"
-                " WHERE newExp.exp_id IS NOT NULL"
-                " AND rawScienceExp.exp_id IS NULL"
-                " AND rawDetrendExp.exp_id IS NULL) AS foo"
-        ); // WHERE class is generated from exp_id, class, & class_id
+                " LEFT JOIN newExp USING(exp_tag)"
+                " LEFT JOIN rawScienceExp USING(exp_tag)"
+                " LEFT JOIN rawDetrendExp USING (exp_tag)"
+                " WHERE newExp.exp_tag IS NOT NULL"
+                " AND rawScienceExp.exp_tag IS NULL"
+                " AND rawDetrendExp.exp_tag IS NULL) AS foo"
+        ); // WHERE class is generated from exp_tag, class, & class_id
 
     {
-        // build a query to search by exp_id, class, class_id
+        // build a query to search by exp_tag, class, class_id
         psMetadata *where = psMetadataAlloc();
         bool status = false;
-        psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+        psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
         if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
             psFree(query);
             return false;
         }
-        if (exp_id) {
-            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
+        if (exp_tag) {
+            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
                 psFree(where);
                 psFree(query);
@@ -619,5 +619,5 @@
 {
     return p1PendingExpRowAlloc(
-        newExp->exp_id,
+        newExp->exp_tag,
         newExp->camera,
         newExp->telescope,
@@ -642,5 +642,5 @@
 
     return p2PendingExpRowAlloc(
-        exp->exp_id,
+        exp->exp_tag,
         "my recipe",
         0xff, // XXX calc version number
@@ -652,5 +652,5 @@
 {
     return p2PendingImfileRowAlloc(
-        rawImfile->exp_id,
+        rawImfile->exp_tag,
         rawImfile->class_id,
         rawImfile->uri,
@@ -796,5 +796,5 @@
 
     return rawDetrendExpRowAlloc(
-        exp->exp_id,
+        exp->exp_tag,
         exp->camera,
         exp->telescope,
@@ -941,5 +941,5 @@
 
     return rawImfileRowAlloc(
-        imfile->exp_id,
+        imfile->exp_tag,
         imfile->class,
         imfile->class_id,
