Index: trunk/ippTools/src/camtool.c
===================================================================
--- trunk/ippTools/src/camtool.c	(revision 12093)
+++ trunk/ippTools/src/camtool.c	(revision 12131)
@@ -100,12 +100,14 @@
             "   rawExp.workdir"
             " FROM camPendingExp"
+            " JOIN chipProcessedExp"
+            "   USING(chip_id)"
             " JOIN rawExp"
-            "   USING(exp_tag)"
+            "   ON chipProcessedExp.exp_tag = rawExp.exp_tag"
             " LEFT JOIN camProcessedExp"
-            "   USING(exp_tag)"
+            "   on camPendingExp.cam_id = camPendingExp.cam_id"
             " LEFT JOIN camMask"
             "   ON camPendingExp.label = camMask.label"
             " WHERE"
-            "   camProcessedExp.exp_tag IS NULL"
+            "   camProcessedExp.cam_id IS NULL"
             "   AND camMask.label IS NULL"
     );
@@ -152,4 +154,10 @@
     }
 
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
     // negate simple so the default is true
     if (!ippdbPrintMetadatas(stdout, output, "camPendingExp", !simple)) {
@@ -170,4 +178,5 @@
     psString query = psStringCopy(
             "SELECT"
+            "   camPendingExp.cam_id,"
             "   chipProcessedImfile.*,"
             "   rawExp.camera,"
@@ -175,13 +184,13 @@
             " FROM camPendingExp"
             " JOIN chipProcessedImfile"
-            "   USING(exp_tag, chip_version)"
+            "   USING(chip_id)"
             " JOIN rawExp"
-            "   USING(exp_tag)"
+            "   ON chipProcessedImfile.exp_tag = rawExp.exp_tag"
             " LEFT JOIN camProcessedExp"
-            "   USING(exp_tag)"
+            "   ON camPendingExp.cam_id = camProcessedExp.cam_id"
             " LEFT JOIN camMask"
             "   ON camPendingExp.label = camMask.label"
             " WHERE"
-            "   camProcessedExp.exp_tag IS NULL"
+            "   camProcessedExp.cam_id IS NULL"
             "   AND camMask.label IS NULL"
     );
@@ -221,4 +230,28 @@
     }
 
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
     // negate simple so the default is true
     if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
@@ -237,16 +270,15 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // det_id, exp_tag, recip
-    // are required
     bool status = false;
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
-        return false;
-    }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
-        return false;
-    }
+    psString cam_id = psMetadataLookupStr(&status, config->args, "-cam_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -cam_id");
+        return false;
+    }
+    if (!cam_id) {
+        psError(PS_ERR_UNKNOWN, true, "-cam_id is required");
+        return false;
+    }
+
     psString uri = psMetadataLookupStr(&status, config->args, "-uri");
     if (!status) {
@@ -258,4 +290,5 @@
         return false;
     }
+
     psString recipe = psMetadataLookupStr(&status, config->args, "-recip");
     if (!status) {
@@ -267,4 +300,5 @@
         return false;
     }
+
     psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");
     if (!status) {
@@ -272,4 +306,5 @@
         return false;
     }
+
     psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");
     if (!status) {
@@ -277,4 +312,5 @@
         return false;
     }
+
     psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev");
     if (!status) {
@@ -282,4 +318,5 @@
         return false;
     }
+
     psF32 sigma_ra = psMetadataLookupF32(&status, config->args, "-sigma_ra");
     if (!status) {
@@ -291,4 +328,5 @@
         return false;
     }
+
     psF32 sigma_dec = psMetadataLookupF32(&status, config->args, "-sigma_dec");
     if (!status) {
@@ -300,4 +338,5 @@
         return false;
     }
+
     psS32 nastro = psMetadataLookupS32(&status, config->args, "-nastro");
     if (!status) {
@@ -309,4 +348,5 @@
         return false;
     }
+
     psF32 zp_mean = psMetadataLookupF32(&status, config->args, "-zp_mean");
     if (!status) {
@@ -318,4 +358,5 @@
         return false;
     }
+
     psF32 zp_stdev = psMetadataLookupF32(&status, config->args, "-zp_stdev");
     if (!status) {
@@ -346,11 +387,11 @@
         " FROM camPendingExp"
         " LEFT JOIN camProcessedExp"
-        "   USING(exp_tag)"
+        "   USING(cam_id)"
         " WHERE"
-        "   camProcessedExp.exp_tag IS NULL"
-        "   AND camPendingExp.exp_tag = '%s'"
+        "   camProcessedExp.cam_id IS NULL"
+        "   AND camPendingExp.cam_id = '%s'"
     );
 
-    if (!p_psDBRunQuery(config->dbh, query, exp_tag)) {
+    if (!p_psDBRunQuery(config->dbh, query, cam_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(query);
@@ -382,7 +423,6 @@
     // create a new camProcessedImfile object
     camProcessedExpRow *row = camProcessedExpRowAlloc(
-        exp_tag,
-        pendingRow->cam_version,
-        pendingRow->chip_version,
+        pendingRow->cam_id,
+        pendingRow->chip_id,
         pendingRow->label,
         uri,
@@ -437,4 +477,5 @@
 }
 
+
 static bool processedexpMode(pxConfig *config)
 {
@@ -460,8 +501,10 @@
             "   rawExp.workdir"
             " FROM camProcessedExp"
+            " JOIN chipProcessedExp"
+            "   USING(chip_id)"
             " JOIN rawExp"
-            "   USING(exp_tag)"
+            "   chipProcessedExp.exp_tag = rawExp.exp_tag"
             " WHERE"
-            "   camProcessedExp.exp_tag IS NOT NULL"
+            "   camProcessedExp.cam_id IS NOT NULL" // bongus
     );
 
@@ -515,4 +558,28 @@
     }
 
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
     // negate simple so the default is true
     if (!ippdbPrintMetadatas(stdout, output, "camProcessedExp", !simple)) {
@@ -570,4 +637,5 @@
     return true;
 }
+
 
 static bool maskedMode(pxConfig *config)
@@ -605,4 +673,10 @@
     }
 
+    if (!convertIdToStr(output)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
+        psFree(output);
+        return false;
+    }
+
     // negative simple so the default is true
     if (!ippdbPrintMetadatas(stdout, output, "camMask", !simple)) {
@@ -617,4 +691,5 @@
 }
 
+
 static bool unblockMode(pxConfig *config)
 {
