Index: /branches/eam_branches/ipp-20121219/ippToPsps/jython/detectionbatch.py
===================================================================
--- /branches/eam_branches/ipp-20121219/ippToPsps/jython/detectionbatch.py	(revision 35059)
+++ /branches/eam_branches/ipp-20121219/ippToPsps/jython/detectionbatch.py	(revision 35060)
@@ -3,6 +3,8 @@
 import os.path
 import sys
+import glob
 import time
 import stilts
+
 from java.lang import *
 from java.sql import *
@@ -529,5 +531,5 @@
     Populates the DetectionCalib table for this OTA
     '''
-    def populateDetectionCalibTable(self, ota):
+    def populateDetectionCalibTableUpdateInsert(self, ota):
 
         tableName = "DetectionCalib_" + ota
@@ -570,4 +572,51 @@
         self.scratchDb.execute(sql)
         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
+        
+    '''
+    Populates the DetectionCalib table for this OTA
+    '''
+    def populateDetectionCalibTable(self, ota):
+
+        # target table name:
+        tableName = "DetectionCalib_" + ota
+        # drop then re-create table
+        self.scratchDb.dropTable(tableName)
+        sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib"
+        try: self.scratchDb.execute(sql)
+        except: pass
+
+        dumpFile = "/tmp/datadump/genetest.xx.dat"
+        files = glob.glob(dumpFile)
+        if len(files) > 0:
+            os.unlink(dumpFile)
+
+        # insert all detections into table
+        sql = "SELECT \
+          a.objID,    \
+          a.detectID, \
+          a.ippObjID,      \
+          a.ippDetectID,   \
+          a.filterID,      \
+          a.surveyID,      \
+          b.ra,            \
+          b.dec_,          \
+          b.raErr,         \
+          b.decErr,        \
+          b.zp,            \
+          b.zpErr,         \
+          b.expTime,       \
+          b.airMass,       \
+          " + str(self.config.dataRelease) + " \
+         FROM              \
+           Detection_" + ota + " as a \
+         JOIN " + self.scratchDb.dvoDetectionTable + " as b \
+         ON (a.objID = b.objID AND a.detectID = b.detectID) \
+         INTO OUTFILE '" + dumpFile + "'"
+        print "sql: ", sql
+        self.scratchDb.execute(sql)
+
+        sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName
+        print "sql: ", sql
+        self.scratchDb.execute(sql)
         
     '''
Index: /branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py
===================================================================
--- /branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py	(revision 35059)
+++ /branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py	(revision 35060)
@@ -787,5 +787,5 @@
           b.expTime,       \
           b.airMass,       \
-          a.dataRelease    \
+          " + str(self.config.dataRelease) + " \
          FROM              \
            StackDetection as a \
@@ -799,5 +799,7 @@
         print "sql: ", sql
         self.scratchDb.execute(sql)
-        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
+
+        ## XXX write this with the select/insert
+        # self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
 
     '''
