Index: branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py
===================================================================
--- branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py	(revision 37218)
+++ branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py	(revision 37219)
@@ -620,4 +620,8 @@
                             tarballFile)
 
+        if self.config.onebatch:
+            self.logger.infoPair("onebatch requested", "exiting")
+            sys.exit(0)
+
 # XXX why is this down here??
 from datastore import Datastore
Index: branches/eam_branches/ipp-20140717/ippToPsps/jython/config.py
===================================================================
--- branches/eam_branches/ipp-20140717/ippToPsps/jython/config.py	(revision 37218)
+++ branches/eam_branches/ipp-20140717/ippToPsps/jython/config.py	(revision 37219)
@@ -26,4 +26,5 @@
         self.retry = False
         self.camera = "gpc1"
+        self.onebatch = False
 
         if sys.argv.count("-test"):
@@ -56,4 +57,8 @@
             self.camera = "simtest"
             sys.argv.remove("-simtest")
+
+        if sys.argv.count("-one-batch"):
+            self.onebatch = True
+            sys.argv.remove("-one-batch")
 
         ## name of the top-level jython script
Index: branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py
===================================================================
--- branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py	(revision 37218)
+++ branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py	(revision 37219)
@@ -580,5 +580,5 @@
                a.detectID     = b.detectID, \
                a.ippObjID     = b.ippObjID, \
-               a.dvoRegionID  = b.catID \
+               a.dvoRegionID  = b.catID, \
                a.ra           = b.ra, \
                a.dec          = b.dec_, \
Index: branches/eam_branches/ipp-20140717/ippToPsps/jython/objectbatch.py
===================================================================
--- branches/eam_branches/ipp-20140717/ippToPsps/jython/objectbatch.py	(revision 37218)
+++ branches/eam_branches/ipp-20140717/ippToPsps/jython/objectbatch.py	(revision 37219)
@@ -137,5 +137,5 @@
                    " + cpsTable + " AS cps ON (cps.row = (MeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
                    SET \
-                    MeanObject." + filter[1] + "QfPerfect = -999 \
+                    MeanObject." + filter[1] + "QfPerfect      = PSF_QF_PERF_MAX \
                    ,MeanObject." + filter[1] + "MeanPSFMag     = MAG \
                    ,MeanObject." + filter[1] + "MeanPSFMagErr  = MAG_ERR \
@@ -192,8 +192,16 @@
 
             # XXX EAM 20140724 : this is quite awkward, add a objRow and ncode value to mysql db table?
-            sql = "UPDATE ObjectThin JOIN \
-                   " + cpsTable + " AS cps ON (cps.row = (ObjectThin.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
-                   SET \
-                   ObjectThin.n" + filter[1] + " = NCODE "
+            # sqlLine = sqlUtility()
+
+            sql  = "UPDATE ObjectThin JOIN "
+            sql += cpsTable + " AS cps "
+            sql += "ON (cps.row = (ObjectThin.row * "
+            sql += str(filterCount) + ")-(" 
+            sql += str(filterCount) + " - " 
+            sql += str(filter[0])
+            sql += ")) "
+
+            sql += "SET ObjectThin.n" + filter[1] + " = NCODE, "
+            sql += "ObjectThin.nStackDetections = ObjectThin.nStackDetections + cps.NSTACK_DET"
             self.logger.info(sql)
             self.scratchDb.execute(sql)
@@ -203,7 +211,7 @@
         for filter in filters:
             # now do a sum of n[filters], but do not include the ones with -999
-            sql = "UPDATE ObjectThin   \
-                   SET nDetections = nDetections + n" + filter[1] + " \
-                   WHERE n" + filter[1] + " != -999"
+            sql  = "UPDATE ObjectThin "
+            sql += "SET nDetections = nDetections + n" + filter[1]
+            sql += " WHERE n" + filter[1] + " != -999"
             self.scratchDb.execute(sql)
 
@@ -329,4 +337,7 @@
         sqlLine.group("batchID",         "'" + str(self.batchID) + "'")
         sqlLine.group("dvoRegionID",     "CAT_ID") 
+        sqlLine.group("tessID",          "TESS_ID") 
+        sqlLine.group("projectionID",    "PROJECTION_ID") 
+        sqlLine.group("skycellID",       "SKYCELL_ID") 
         sqlLine.group("dataRelease",     "'" + str(self.skychunk.dataRelease) + "'")
         sqlLine.group("objInfoFlag",     "FLAGS") 
@@ -428,12 +439,5 @@
         self.logger.infoPair("Populating MeanObject from ", "ObjectThin")
 
-        sql = "INSERT INTO MeanObject ( \
-               objID \
-               ,gcobjID \
-               ) \
-               SELECT \
-               objID \
-               ,gcobjID \
-               FROM ObjectThin"
+        sql = "INSERT INTO MeanObject ( objID ) SELECT objID FROM ObjectThin"
         try:
             self.scratchDb.execute(sql)
