Index: /trunk/ippTools/src/dettoolConfig.c
===================================================================
--- /trunk/ippTools/src/dettoolConfig.c	(revision 7821)
+++ /trunk/ippTools/src/dettoolConfig.c	(revision 7822)
@@ -416,4 +416,7 @@
     // setup search criterion
 #define addWhereStr(name) \
+{ \
+    psString str = NULL; \
+    bool status = false; \
     if ((str = psMetadataLookupStr(&status, config->args, "-" #name))) { \
         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
@@ -421,20 +424,19 @@
             goto FAIL; \
         } \
-    }
+    } \
+}
 
     // generate SQL where claus
     config->where = psMetadataAlloc();
 
-{
-    psString str = NULL;
-    int n = 0;
-    bool status = false;
-    bool boolean = false;
-
     addWhereStr(det_id);
-    if ((n = psMetadataLookupS32(&status, config->args, "-iteration"))) {
-        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "iteration", 0, "==", n)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
-            goto FAIL;
+    {
+        int n = 0;
+        bool status = false;
+        if ((n = psMetadataLookupS32(&status, config->args, "-iteration"))) {
+            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "iteration", 0, "==", n)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
+                goto FAIL;
+            }
         }
     }
@@ -443,16 +445,24 @@
     addWhereStr(class_id);
     // convert '-inst' to 'camera'
-    if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) {
-        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
-            goto FAIL;
+    {
+        psString str = NULL;
+        bool status = false;
+        if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) {
+            if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
+                goto FAIL;
+            }
         }
     }
     addWhereStr(telescope);
     addWhereStr(exp_type);
-    if ((n = psMetadataLookupS32(&status, config->args, "-imfiles"))) {
-        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
-            goto FAIL;
+    {
+        int n = 0;
+        bool status = false;
+        if ((n = psMetadataLookupS32(&status, config->args, "-imfiles"))) {
+            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
+                goto FAIL;
+            }
         }
     }
@@ -460,17 +470,25 @@
     addWhereStr(stats);
     addWhereStr(recipe);
-    if ((n = psMetadataLookupS32(&status, config->args, "-p1_version"))) {
-        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
-            goto FAIL;
+    {
+        int n = 0;
+        bool status = false;
+        if ((n = psMetadataLookupS32(&status, config->args, "-p1_version"))) {
+            if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
+                goto FAIL;
+            }
         }
     }
-    if ((boolean = psMetadataLookupBool(&status, config->args, "-accept"))) {
-        if (!psMetadataAddBool(config->where, PS_LIST_TAIL, "accept", 0, "==", boolean)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item accept");
-            goto FAIL;
+    {
+        bool boolean = false;
+        bool status = false;
+
+        if ((boolean = psMetadataLookupBool(&status, config->args, "-accept"))) {
+            if (!psMetadataAddBool(config->where, PS_LIST_TAIL, "accept", 0, "==", boolean)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item accept");
+                goto FAIL;
+            }
         }
     }
-}
 
     if (config->where->list->n < 1) {
