Index: /branches/eam_branches/ipp-20121219/ippToPsps/jython/gpc1db.py
===================================================================
--- /branches/eam_branches/ipp-20121219/ippToPsps/jython/gpc1db.py	(revision 35056)
+++ /branches/eam_branches/ipp-20121219/ippToPsps/jython/gpc1db.py	(revision 35057)
@@ -237,6 +237,4 @@
         else:
             files = glob.glob(path + ".smf")
-
-            
 
         # XXX EAM : test output
Index: /branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py
===================================================================
--- /branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py	(revision 35056)
+++ /branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py	(revision 35057)
@@ -2,4 +2,5 @@
 
 import os.path
+import glob
 import sys
 
@@ -717,5 +718,5 @@
     calling the load data infile '/tmp/name' into table;
     '''
-    def populateStackDetectionCalib(self):
+    def populateStackDetectionCalibInsertUpdate(self):
         self.logger.infoPair("Processing table", "StackDetectionCalib")
         tableName = "StackDetectionCalib"
@@ -757,6 +758,46 @@
         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
         
-    
-
+    def populateStackDetectionCalib(self):
+
+        tableName = "StackDetectionCalib"
+        self.logger.infoPair("Processing table", tableName)
+
+        imageID = self.scratchDb.getImageIDFromExternID(self.header['IMAGEID'])
+        self.logger.infoPair("obtained","imageID")
+
+        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.stackDetectID, \
+          a.ippObjID,      \
+          a.ippDetectID,   \
+          a.filterID,      \
+          a.surveyID,      \
+          b.ra,            \
+          b.dec_,          \
+          b.raErr,         \
+          b.decErr,        \
+          b.zp,            \
+          b.zpErr,         \
+          b.expTime,       \
+          b.airMass,       \
+          a.dataRelease    \
+         FROM              \
+           StackDetection as a \
+         JOIN " + self.scratchDb.dvoDetectionTable + " as b \
+         ON (a.stackDetectID = b.detectID) where b.imageID = " + str(imageID) + \
+         " 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)
+        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
 
     '''
