Index: trunk/ippTools/src/camtool.c
===================================================================
--- trunk/ippTools/src/camtool.c	(revision 12188)
+++ trunk/ippTools/src/camtool.c	(revision 12189)
@@ -94,22 +94,9 @@
     }
 
-    psString query = psStringCopy(
-            "SELECT"
-            "   camPendingExp.*,"
-            "   rawExp.camera,"
-            "   rawExp.workdir"
-            " FROM camPendingExp"
-            " JOIN chipProcessedExp"
-            "   USING(chip_id)"
-            " JOIN rawExp"
-            "   ON chipProcessedExp.exp_tag = rawExp.exp_tag"
-            " LEFT JOIN camProcessedExp"
-            "   on camPendingExp.cam_id = camPendingExp.cam_id"
-            " LEFT JOIN camMask"
-            "   ON camPendingExp.label = camMask.label"
-            " WHERE"
-            "   camProcessedExp.cam_id IS NULL"
-            "   AND camMask.label IS NULL"
-    );
+    psString query = pxDataGet("camtool_find_pendingexp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
 
     if (config->where) {
@@ -176,25 +163,9 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    psString query = psStringCopy(
-            "SELECT"
-            "   camPendingExp.cam_id,"
-            "   chipProcessedImfile.*,"
-            "   rawExp.camera,"
-            "   rawExp.workdir"
-            " FROM camPendingExp"
-            " JOIN chipProcessedExp"
-            "   USING(chip_id)"
-            " JOIN chipProcessedImfile"
-            "   USING(chip_id)"
-            " JOIN rawExp"
-            "   ON chipProcessedExp.exp_tag = rawExp.exp_tag"
-            " LEFT JOIN camProcessedExp"
-            "   ON camPendingExp.cam_id = camProcessedExp.cam_id"
-            " LEFT JOIN camMask"
-            "   ON camPendingExp.label = camMask.label"
-            " WHERE"
-            "   camProcessedExp.cam_id IS NULL"
-            "   AND camMask.label IS NULL"
-    );
+    psString query = pxDataGet("camtool_find_pendingimfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
 
     if (config->where) {
@@ -238,22 +209,4 @@
     }
 
-    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)) {
@@ -375,13 +328,9 @@
     }
 
-    psString query = psStringCopy(
-        "SELECT camPendingExp.*"
-        " FROM camPendingExp"
-        " LEFT JOIN camProcessedExp"
-        "   USING(cam_id)"
-        " WHERE"
-        "   camProcessedExp.cam_id IS NULL"
-        "   AND camPendingExp.cam_id = '%s'"
-    );
+    psString query = pxDataGet("camtool_find_pendingexp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
 
     if (!p_psDBRunQuery(config->dbh, query, cam_id)) {
@@ -487,17 +436,9 @@
     }
 
-    psString query = psStringCopy(
-            "SELECT"
-            "   camProcessedExp.*,"
-            "   rawExp.camera,"
-            "   rawExp.workdir"
-            " FROM camProcessedExp"
-            " JOIN chipProcessedExp"
-            "   USING(chip_id)"
-            " JOIN rawExp"
-            "   chipProcessedExp.exp_tag = rawExp.exp_tag"
-            " WHERE"
-            "   camProcessedExp.cam_id IS NOT NULL" // bongus
-    );
+    psString query = pxDataGet("camtool_find_processedexp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
 
     if (config->where) {
@@ -556,22 +497,4 @@
     }
 
-    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)) {
