Index: trunk/ippTools/src/camtool.c
===================================================================
--- trunk/ippTools/src/camtool.c	(revision 9271)
+++ trunk/ippTools/src/camtool.c	(revision 9272)
@@ -58,23 +58,18 @@
     // and have no associated imfiles left in newImfile
 
-    char *query =
-        "SELECT newExp.*"
-        " FROM newExp"
-        " 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"
-        "   AND rawScienceExp.exp_tag IS NULL"
-        "   AND newExp.imfiles ="
-        "   (SELECT COUNT(exp_tag) FROM rawImfile"
-        "       WHERE rawImfile.exp_tag = newExp.exp_tag)"
-        ;
+    psString query = psStringCopy("SELECT * FROM p3PendingExp");
+
+    if (config->where) {
+        psString whereClause = psDBGenerateWhereSQL(config->where, NULL);
+        psStringAppend(&query, " %s", whereClause);
+        psFree(whereClause);
+    }
 
     if (!p_psDBRunQuery(config->dbh, query)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(query);
         return false;
     }
+    psFree(query);
 
     psArray *output = p_psDBFetchResult(config->dbh);
@@ -85,5 +80,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no pending newExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no p3PendingExp rows found");
         psFree(output);
         return true;
@@ -101,5 +96,5 @@
 
     // negate simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "newImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "p3PendingExp", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
Index: trunk/ippTools/src/camtoolConfig.c
===================================================================
--- trunk/ippTools/src/camtoolConfig.c	(revision 9271)
+++ trunk/ippTools/src/camtoolConfig.c	(revision 9272)
@@ -24,15 +24,11 @@
     // -pendingexp
     psMetadata *pendingexpArgs = psMetadataAlloc();
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_tag",  0,
+    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_tag", 0,
         "search by exposure ID", NULL);
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-inst",  0,
-        "search by camera", NULL);
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-telescope",  0,
-        "search by telescope", NULL);
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_type",  0,
-        "search by exposure type", NULL);
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-imfiles",  0,
-        "search for exps with N imfiles", NULL);
-    psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple",  0,
+    psMetadataAddS32(pendingexpArgs, PS_LIST_TAIL, "-p2_version", 0,
+        "search for exposures with this p2 version", -1);
+    psMetadataAddS32(pendingexpArgs, PS_LIST_TAIL, "-p3_version", 0,
+        "search for exposures with this p3 version", -1);
+    psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0,
         "use the simple output format", false);
     
