Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 7293)
+++ trunk/ippTools/src/dettool.c	(revision 7299)
@@ -100,7 +100,14 @@
 {
     bool status     = false;
-    psString str    = NULL;
 
     PS_ASSERT_PTR_NON_NULL(config, false);
+
+    // what type of detRun is this?
+    psString det_type = psMetadataLookupStr(&status, config->args, "-det_type");
+    // this flag is required
+    if (!det_type) {
+        psError(PS_ERR_UNKNOWN, true, "-det_type is required");
+        return false;
+    }    
 
     // start a transaction so we don't end up with orphaned det_ids
@@ -109,8 +116,4 @@
         return false;
     }
-
-    // what type of detRun is this?
-    // XXX make this flag required
-    psString det_type = psMetadataLookupStr(&status, config->args, "-det_type");
     detRunInsert(config->dbh, det_type);
     long det_id = psDBLastInsertID(config->dbh);
@@ -120,11 +123,23 @@
     psMetadata *where = psMetadataAlloc();
 
-    // was more then one exp_id specified?
+    // make sure that -exp_id was parsed correctly
+    // XXX this can be removed someday
     if (item->type == PS_DATA_METADATA_MULTI) {
-        // yes
         psListIterator *iter = psListIteratorAlloc(item->data.list, 0, false);
         psMetadataItem *mItem = NULL;
         while ((mItem = psListGetAndIncrement(iter))) {
             psString exp_id = mItem->data.V;
+            // if exp_id is NULL then it means that -exp_id has not specified
+            if (!exp_id) {
+                psError(PS_ERR_UNKNOWN, true,
+                        "at least one -exp_id is required");
+                // rollback
+                if (!psDBRollback(config->dbh)) {
+                    psError(PS_ERR_UNKNOWN, false, "database error");
+                }
+                psFree(where);
+                return false;
+            }
+
             if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id",
                         PS_META_DUPLICATE_OK, "==", exp_id)) {
@@ -139,15 +154,11 @@
             }
         }
-    } else if ((str = psMetadataLookupStr(&status, config->args, "-exp_id"))) {
-        // no
-        if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", str)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
-            // rollback
-            if (!psDBRollback(config->dbh)) {
-                psError(PS_ERR_UNKNOWN, false, "database error");
-            }
-            psFree(where);
-            return false;
-        }
+    } else {
+        // rollback
+        if (!psDBRollback(config->dbh)) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+        }
+        psAbort(config->argv[0],
+                "-exp_id was not parsed correctly (this should not happen");
     }
 
