Index: trunk/ippTools/src/regtool.c
===================================================================
--- trunk/ippTools/src/regtool.c	(revision 12076)
+++ trunk/ippTools/src/regtool.c	(revision 12086)
@@ -25,4 +25,5 @@
 
 #include "pxtools.h"
+#include "pxdata.h"
 #include "regtool.h"
 
@@ -112,17 +113,9 @@
     // that should be checked for
 
-    psString query = psStringCopy(
-        "SELECT\n"
-        "   newImfile.*,\n"
-        "   newExp.workdir\n"
-        " FROM newImfile\n"
-        " LEFT JOIN newExp\n"
-        "   USING(exp_tag)\n"
-        " LEFT JOIN rawExp\n"
-        "   USING(exp_tag)\n"
-        " WHERE\n"
-        "   newExp.exp_tag is NOT NULL\n"
-        "   AND rawExp.exp_tag IS NULL\n"
-    );
+    psString query = pxDataGet("regtool_pendingimfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     // treat limit == 0 as "no limit"
@@ -184,16 +177,9 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // XXX search by the whole frame some imfiles without a newExp don't get
-    // processed -- this may not be the correct thing to do
-    psString query = psStringCopy(
-        "SELECT\n"
-        "   *\n"
-        " FROM\n"
-        "   (SELECT newImfile.* FROM newImfile\n"
-        "       LEFT JOIN newExp USING(exp_tag)\n"
-        "       LEFT JOIN rawExp USING(exp_tag)\n"
-        "       WHERE newExp.exp_tag IS NOT NULL\n"
-        "       AND rawExp.exp_tag IS NULL) as Foo\n"
-        ); // WHERE class is generated from exp_tag, class, & class_id
+    psString query = pxDataGet("regtool_find_unprocessed_imfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     {
@@ -363,11 +349,9 @@
     }
 
-    // find all rawImfiles matching the default query
-    psString query = psStringCopy( 
-        "SELECT\n"
-        "   *\n"
-        " FROM rawImfile\n"
-        " WHERE rawImfile.exp_tag is NOT NULL\n" //bogus conditional so there is a where clause to append to
-    );
+    psString query = pxDataGet("regtool_processedimfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     if (config->where) {
@@ -479,22 +463,9 @@
     // have ALL of their imfiles in rawImfile (by count)
     // and have no associated imfiles left in newImfile
-
-    psString query = psStringCopy(
-        "SELECT"
-        "   newExp.*"
-        " FROM newExp"
-        " LEFT JOIN newImfile"
-        "   USING(exp_tag)"
-        " LEFT JOIN rawExp"
-        "   USING(exp_tag)"
-        " WHERE"
-        "   newImfile.exp_tag IS NULL"
-        "   AND rawExp.exp_tag IS NULL"
-        "   AND newExp.imfiles ="
-        "   (SELECT COUNT(exp_tag) FROM rawImfile"
-        "       WHERE"
-        "           rawImfile.exp_tag = newExp.exp_tag"
-        "           AND rawImfile.fault = 0)"
-    );
+    psString query = pxDataGet("regtool_pendingexp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     // treat limit == 0 as "no limit"
@@ -578,20 +549,9 @@
     }
 
-   char *query = 
-        "SELECT"
-        "   newExp.*"
-        " FROM newExp"
-        " LEFT JOIN newImfile"
-        "   USING(exp_tag)"
-        " LEFT JOIN rawExp"
-        "   USING(exp_tag)"
-        " WHERE"
-        "   newExp.exp_tag IS NOT NULL"
-        "   AND newImfile.exp_tag IS NULL"
-        "   AND rawExp.exp_tag IS NULL"
-        "   AND newExp.imfiles ="
-        "   (SELECT COUNT(exp_tag) FROM rawImfile"
-        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
-        "   AND newExp.exp_tag = '%s'";
+    psString query = pxDataGet("regtool_find_unprocessed_exp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     if (!p_psDBRunQuery(config->dbh, query, exp_tag)) {
@@ -794,12 +754,9 @@
     }
 
-    // find all rawImfiles matching the default query
-    psString query = psStringCopy( 
-        "SELECT\n"
-        "   *\n"
-        " FROM rawExp\n"
-        " WHERE\n"
-        "   rawExp.exp_tag IS NOT NULL\n" // bogus where clause
-    );
+    psString query = pxDataGet("regtool_processedexp.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statment");
+        return false;
+    }
 
     if (config->where) {
