Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 12105)
+++ trunk/ippTools/src/warptool.c	(revision 12131)
@@ -239,18 +239,11 @@
     }
 
-    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;
-    }
-
-    // defaults to 0
-    psS32 cam_version = psMetadataLookupS32(&status, config->args, "-cam_version");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -cam_version");
+    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;
     }
@@ -267,7 +260,6 @@
     // constrants
     if (!warpInputExpInsert(config->dbh,
-            (psS32)atoi(warp_id),
-            exp_tag,
-            cam_version,
+            (psS64)atoll(warp_id),
+            (psS64)atoll(cam_id),
             magiced
         )) {
@@ -299,6 +291,5 @@
         "   USING(warp_id)\n"
         " JOIN camProcessedExp\n"
-        "   ON warpInputExp.exp_tag = camProcessedExp.exp_tag\n"
-        "   AND warpInputExp.cam_version = camProcessedExp.cam_version\n"
+        "   ON warpInputExp.cam_id = camProcessedExp.cam_id\n"
         " WHERE\n"
         "   warpRun.state = 'run'\n"
@@ -357,4 +348,10 @@
 
     if (psArrayLength(output)) {
+        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, "warpInputExp", !simple)) {
@@ -386,10 +383,14 @@
         "SELECT\n"
         "   rawImfile.*,\n"
-        "   warpInputExp.cam_version\n"
+        "   warpInputExp.cam_id\n"
         " FROM warpRun\n"
         " JOIN warpInputExp\n"
         "   USING(warp_id)\n"
+        " JOIN camProcessedExp\n"
+        "   ON warpInputExp.cam_id = camProcessedExp.cam_id"
+        " JOIN chipProcessedExp\n"
+        "   ON camProcessedExp.chip_id = chipProcessedExp.chip_id"
         " JOIN rawImfile\n" // is there any reason not to refer back to rawimfiles?
-        "   ON warpInputExp.exp_tag = rawImfile.exp_tag\n"
+        "   ON chipProcessedExp.exp_tag = rawImfile.exp_tag\n"
         " WHERE\n"
         "   warpRun.state = 'run'\n"
@@ -446,4 +447,10 @@
 
     if (psArrayLength(output)) {
+        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, "warpInputImfile", !simple)) {
@@ -482,18 +489,17 @@
         "   USING(warp_id)\n"
         " JOIN camProcessedExp\n"
-        "   ON warpInputExp.exp_tag = camProcessedExp.exp_tag\n"
-        "   AND warpInputExp.cam_version = camProcessedExp.cam_version\n"
+        "   ON warpInputExp.cam_id = camProcessedExp.cam_id\n"
+        " JOIN chipProcessedExp\n"
+        "   ON camProcessedExp.chip_id = chipProcessedExp.chip_id"
         " JOIN rawExp\n"
-        "   ON camProcessedExp.exp_tag = rawExp.exp_tag\n"
+        "   ON chipProcessedExp.exp_tag = rawExp.exp_tag\n"
         " LEFT JOIN warpSkyCellMap\n"
         "   ON warpInputExp.warp_id = warpSkyCellMap.warp_id\n"
-        "   AND warpInputExp.exp_tag = warpSkyCellMap.exp_tag\n"
-        "   AND warpInputExp.cam_version = warpSkyCellMap.cam_version\n"
+        "   AND warpInputExp.cam_id = warpSkyCellMap.cam_id\n"
         " WHERE\n"
         "   warpRun.state = 'run'\n"
         "   AND camProcessedExp.fault = 0\n"
         "   AND warpSkyCellMap.warp_id IS NULL\n"
-        "   AND warpSkyCellMap.exp_tag IS NULL\n"
-        "   AND warpSkyCellMap.cam_version IS NULL\n"
+        "   AND warpSkyCellMap.cam_id IS NULL\n"
     );
 
@@ -549,4 +555,10 @@
 
     if (psArrayLength(output)) {
+        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, "warpInputExp", !simple)) {
@@ -681,6 +693,8 @@
         " JOIN warpSkyCellMap\n"
         "   USING(warp_id)\n"
+        " JOIN camProcessedExp\n"
+        "   ON warpSkyCellMap.cam_id = camProcessedExp.cam_id"
         " JOIN chipProcessedImfile\n"
-        "   ON warpSkyCellMap.exp_tag = chipProcessedImfile.exp_tag\n"
+        "   ON camProcessedExp.chip_id = chipProcessedImfile.chip_id"
         "   AND warpSkyCellMap.class_id = chipProcessedImfile.class_id\n"
         " WHERE\n"
@@ -739,4 +753,10 @@
 
     if (psArrayLength(output)) {
+        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, "warpSkyCellMap", !simple)) {
@@ -773,6 +793,10 @@
         " JOIN warpSkyCellMap\n"
         "   USING(warp_id)\n"
+        " JOIN camProcessedExp\n"
+        "   ON warpSkyCellMap.cam_id = camProcessedExp.cam_id"
+        " JOIN chipProcessedExp\n"
+        "   ON camProcessedExp.chip_id = chipProcessedExp.chip_id"
         " JOIN rawExp\n"
-        "   ON warpSkyCellMap.exp_tag = rawExp.exp_tag\n"
+        "   ON chipProcessedExp.exp_tag = rawExp.exp_tag\n"
         " LEFT JOIN warpSkyfile\n"
         "   ON warpRun.warp_id = warpSkyfile.warp_id\n"
@@ -837,4 +861,10 @@
 
     if (psArrayLength(output)) {
+        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, "warpPendingSkyCell", !simple)) {
@@ -918,5 +948,5 @@
     // XXX need to validate that this coresponds to an warpInputImfile
     if (!warpSkyfileInsert(config->dbh,
-            (psS32)atoi(warp_id),
+            (psS64)atoll(warp_id),
             skycell_id,
             tess_id,
@@ -1125,4 +1155,10 @@
 
     if (psArrayLength(output)) {
+        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, "warpSkyfile", !simple)) {
