Index: /trunk/ippTools/src/regtool.c
===================================================================
--- /trunk/ippTools/src/regtool.c	(revision 10130)
+++ /trunk/ippTools/src/regtool.c	(revision 10131)
@@ -89,13 +89,17 @@
 
     char *query =
-        "SELECT newExp.*"
+        "SELECT"
+        "   newExp.*"
         " FROM newExp"
-        " LEFT JOIN newImfile USING(exp_tag)"
-        " LEFT JOIN rawScienceExp USING(exp_tag)"
-        " LEFT JOIN rawDetrendExp USING(exp_tag)"
+        " LEFT JOIN newImfile"
+        "   USING(exp_tag)"
+        " LEFT JOIN rawScienceExp"
+        "   USING(exp_tag)"
+        " LEFT JOIN rawDetrendExp"
+        "   USING(exp_tag)"
         " WHERE"
-        "   newExp.exp_tag IS NOT NULL"
-        "   AND newImfile.exp_tag IS NULL"
+        "   newImfile.exp_tag IS NULL"
         "   AND rawScienceExp.exp_tag IS NULL"
+        "   AND rawDetrendExp.exp_tag IS NULL"
         "   AND newExp.imfiles ="
         "   (SELECT COUNT(exp_tag) FROM rawImfile"
@@ -131,5 +135,5 @@
 
     // negate simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "newImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "p0PendingExp", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -209,11 +213,32 @@
     // exp_tag is not in newImfile
     // that the correct count of imfiles is in rawImfile
-
-    psString query = psStringCopy(
-        "SELECT newExp.*"
+   
+    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;
+    }
+
+    bool detrend = psMetadataLookupBool(&status, config->args, "-detrend");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detrend");
+        return false;
+    }
+
+   char *query = psStringCopy(
+        "SELECT"
+        "   newExp.*"
         " FROM newExp"
-        " LEFT JOIN newImfile USING(exp_tag)"
-        " LEFT JOIN rawScienceExp USING(exp_tag)"
-        " LEFT JOIN rawDetrendExp USING(exp_tag)"
+        " LEFT JOIN newImfile"
+        "   USING(exp_tag)"
+        " LEFT JOIN rawScienceExp"
+        "   USING(exp_tag)"
+        " LEFT JOIN rawDetrendExp"
+        "   USING(exp_tag)"
         " WHERE"
         "   newExp.exp_tag IS NOT NULL"
@@ -223,25 +248,11 @@
         "   (SELECT COUNT(exp_tag) FROM rawImfile"
         "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
+        "   AND newExp.exp_tag = '%s'"
         );
 
-    {        
-        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");
-            psFree(query);
-            return false;
-        }
-        if (exp_tag) {
-            psStringAppend(&query, " AND newExp.exp_tag = '%s'", exp_tag);
-        }
-    }
-    
-    if (!p_psDBRunQuery(config->dbh, query)) {
+    if (!p_psDBRunQuery(config->dbh, query, exp_tag)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
-        psFree(query);
-        return false;
-    }
-    psFree(query);
+        return false;
+    }
 
     psArray *output = p_psDBFetchResult(config->dbh);
@@ -251,16 +262,9 @@
     }
     if (!psArrayLength(output)) {
-        // XXX check psError here
         psError(PS_ERR_UNKNOWN, false, "no pending newExp rows found");
         psFree(output);
-        return false;
-    }
-
-    bool status = false;
-    bool detrend = psMetadataLookupBool(&status, config->args, "-detrend");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detrend");
-        return false;
-    }
+        return true;
+    }
+
 
     // start a transaction so we don't end up with an exp in
Index: /trunk/ippTools/src/regtoolConfig.c
===================================================================
--- /trunk/ippTools/src/regtoolConfig.c	(revision 10130)
+++ /trunk/ippTools/src/regtoolConfig.c	(revision 10131)
@@ -71,5 +71,5 @@
     psMetadata *updateexpArgs = psMetadataAlloc();
     psMetadataAddStr(updateexpArgs, PS_LIST_TAIL, "-exp_tag",  0,
-        "exp_tag to operate on", NULL); 
+        "exp_tag to operate on (required)", NULL); 
     psMetadataAddStr(updateexpArgs, PS_LIST_TAIL, "-exp_type",  0,
         "define exposure type", NULL);
