Index: trunk/ippTools/src/dettool_processedimfile.c
===================================================================
--- trunk/ippTools/src/dettool_processedimfile.c	(revision 19621)
+++ trunk/ippTools/src/dettool_processedimfile.c	(revision 23229)
@@ -165,11 +165,4 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    bool hasWhere = false;
-
-    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
-    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
-    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
-    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
-
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-det_id", "detProcessedImfile.det_id", "==");
@@ -179,4 +172,10 @@
     PXOPT_COPY_STR(config->args, where, "-select_mode", "detRun.mode", "==");
 
+    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
+
+    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
+    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
+
     psString query = pxDataGet("dettool_processedimfile.sql");
     if (!query) {
@@ -186,4 +185,5 @@
     }
 
+    bool hasWhere = false;
     if (psListLength(where->list)) {
         psString whereClause = psDBGenerateWhereSQL(where, NULL);
@@ -211,4 +211,5 @@
 
     if (faulted) {
+        // list only faulted rows
 	psStringAppend(&query, " %s", " detProcessedImfile.fault != 0");
     } else {
