Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 37577)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 37586)
@@ -293,4 +293,6 @@
         self.generateRandomIDs()
 
+        self.generateStackDetectRowIDs()
+
         # add indexes StackObjectThin
         self.scratchDb.createIndex("StackObjectThin", "objID")
@@ -382,5 +384,5 @@
         self.logger.infoPair("Procesing table", tablename)
         self.insertDvoIDs(tablename, "StackObjectThin")
-
+        
         # if we are going to add a key, do it here so it is useful
         self.scratchDb.createIndex(tablename, "objID") 
@@ -949,4 +951,14 @@
 
 
+    def generateStackDetectRowIDs(self):
+        sql = "UPDATE StackObjectThin join (select @r:=@r+1 rownum, objID from \
+        (select @r:=0) r, StackObjectThin t) as foo using (objID) set \
+        stackDetectRowID = ((" + str(self.batchID) + " << 32 ) + rownum)";
+        try: self.scratchDb.execute(sql)
+        except:
+            self.logger.errorPair('failed sql',sql)
+            return
+        
+
     '''
     select objID (psps object ID) from dvo restricted to this set of imageIDs. also insert
@@ -1008,5 +1020,7 @@
             if (i < len(self.filters) - 1):
                 fields += ", "
-        
+
+        if (table == "StackObjectAttributes"):
+            fields += "stackDetectRowID, "
         sql  = "INSERT INTO " + table + " (" + fields + ") "
         sql += "SELECT " + fields + " FROM " + mainTable
@@ -1016,5 +1030,7 @@
             self.logger.errorPair('failed sql',sql)
             return
-    
+
+
+        
     '''
     Does the processing, i.e. pulling stuff from IPP tables into PSPS tables
