Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 14268)
+++ trunk/ippTools/src/dettool.c	(revision 14269)
@@ -86,4 +86,5 @@
 static bool adddetrunsummaryMode(pxConfig *config);
 static bool detrunsummaryMode(pxConfig *config);
+static bool revertdetrunsummaryMode(pxConfig *config);
 static bool updatedetrunMode(pxConfig *config);
 static bool rerunMode(pxConfig *config);
@@ -177,4 +178,5 @@
         MODECASE(DETTOOL_MODE_ADDDETRUNSUMMARY, adddetrunsummaryMode);
         MODECASE(DETTOOL_MODE_DETRUNSUMMARY,    detrunsummaryMode);
+        MODECASE(DETTOOL_MODE_REVERTDETRUNSUMMARY, revertdetrunsummaryMode);
         MODECASE(DETTOOL_MODE_UPDATEDETRUN,     updatedetrunMode);
         MODECASE(DETTOOL_MODE_RERUN,            rerunMode);
@@ -5997,4 +5999,5 @@
     psFree(output);
 
+    // XXX this logic does not deal with the case of -code being set
     if (again) {
         if (!startNewIteration(config, (psS64)atoll(det_id))) {
@@ -6177,4 +6180,37 @@
     return true;
 }
+
+
+static bool revertdetrunsummaryMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    psString query = pxDataGet("dettool_revertdetrunsummary.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
+
+    if (config->where) {
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "detRunSummary");
+        psStringAppend(&query, " AND %s", whereClause);
+        psFree(whereClause);
+    }
+
+    if (!p_psDBRunQuery(config->dbh, query)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(query);
+        return false;
+    }
+    psFree(query);
+
+    if (psDBAffectedRows(config->dbh) < 1) {
+        psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
+        return false;
+    }
+
+    return true;
+}
+
 
 static bool updatedetrunMode(pxConfig *config)
