Index: /trunk/ippTools/src/dettool.c
===================================================================
--- /trunk/ippTools/src/dettool.c	(revision 7366)
+++ /trunk/ippTools/src/dettool.c	(revision 7367)
@@ -1505,4 +1505,95 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
+ 
+    // det_id, exp_id, stats, & recipe are required
+    bool status = false;
+    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
+        return false;
+    }
+    if (!det_id) {
+        psError(PS_ERR_UNKNOWN, true, "-det_id is required");
+        return false;
+    }
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
+        return false;
+    }
+    psString stats = psMetadataLookupStr(&status, config->args, "-stats");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");
+        return false;
+    }
+    if (!stats) {
+        psError(PS_ERR_UNKNOWN, true, "-stats is required");
+        return false;
+    }
+    psString recipe = psMetadataLookupStr(&status, config->args, "-recipe");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recipe");
+        return false;
+    }
+    if (!recipe) {
+        psError(PS_ERR_UNKNOWN, true, "-recipe is required");
+        return false;
+    }
+    // accept is optional
+    bool accept = psMetadataLookupBool(&status, config->args, "-accept");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recipe");
+        return false;
+    }
+
+    // check det_id, exp_id against detInputExp
+    
+    // we have to generate our own where claus as we want to exclude -stats
+    // from the search
+    psMetadata *where = psMetadataAlloc();
+    if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
+            (psS32)atoi(det_id))) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");
+        psFree(where);
+        return false;
+    }
+    if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
+        psFree(where);
+        return false;
+    }
+
+    psArray *inputExp = detInputExpSelectRowObjects(config->dbh, where, 0);
+    psFree(where);
+    if (!inputExp) {
+        psError(PS_ERR_UNKNOWN, true,
+    "det_id %s, exp_id %s does not corespond to an input exp", det_id, exp_id);
+        return false;
+    }
+
+    // if we've made it this far then we must have found a match
+    psFree(inputExp);
+
+    // create a new detResidExpAnalysis row and insert it
+    detResidExpAnalysisRow *residExp = detResidExpAnalysisRowAlloc(
+                (psS32)atol(det_id),
+                exp_id,
+                stats,
+                recipe,
+                accept
+            );
+
+    if (!detResidExpAnalysisInsertObject(config->dbh, residExp)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(residExp);
+        return false;
+    }
+
+    psFree(residExp);
+
     return true;
 }
Index: /trunk/ippTools/src/dettoolConfig.c
===================================================================
--- /trunk/ippTools/src/dettoolConfig.c	(revision 7366)
+++ /trunk/ippTools/src/dettoolConfig.c	(revision 7367)
@@ -203,6 +203,4 @@
     psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-exp_id",  0,
         "define detrend ID (required)", NULL);
-    psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-class_id",  0,
-        "define class ID (required)", NULL);
     psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-stats",  0,
         "define stats (required)", NULL);
