Index: /trunk/Ohana/src/dvopsps/include/dvopsps.h
===================================================================
--- /trunk/Ohana/src/dvopsps/include/dvopsps.h	(revision 35577)
+++ /trunk/Ohana/src/dvopsps/include/dvopsps.h	(revision 35578)
@@ -13,4 +13,5 @@
   uint64_t ippObjID;
   uint64_t objID;
+  int      photcode;
   unsigned int flags;
   float zp;
Index: /trunk/Ohana/src/dvopsps/src/DetectionOps.c
===================================================================
--- /trunk/Ohana/src/dvopsps/src/DetectionOps.c	(revision 35577)
+++ /trunk/Ohana/src/dvopsps/src/DetectionOps.c	(revision 35578)
@@ -54,4 +54,5 @@
   GET_COLUMN(ippObjID    , "ippObjID",    int64_t);
   GET_COLUMN(objID       , "objID",       int64_t);
+  GET_COLUMN(photcode    , "photcode",    int);
   GET_COLUMN(flags       , "flags",       int);
   GET_COLUMN(zp          , "zp",          float);
@@ -73,4 +74,5 @@
     detections[i].ippObjID     = ippObjID[i];   
     detections[i].objID        = objID[i];      
+    detections[i].photcode     = photcode[i];      
     detections[i].flags        = flags[i];      
     detections[i].zp           = zp[i];         
@@ -90,4 +92,5 @@
   free (ippObjID   );
   free (objID      );
+  free (photcode   );
   free (flags      );
   free (zp         );
@@ -154,4 +157,5 @@
   // gfits_define_bintable_column (&theader, "K", "ippObjID",    NULL, NULL, 1.0, BZERO_INT64);
   // gfits_define_bintable_column (&theader, "K", "objID",       NULL, NULL, 1.0, BZERO_INT64);
+  gfits_define_bintable_column (&theader, "J", "photcode",    NULL, NULL, 1.0, 0.0);
   gfits_define_bintable_column (&theader, "J", "flags",       NULL, NULL, 1.0, BZERO_INT32);
   gfits_define_bintable_column (&theader, "E", "zp",          NULL, NULL, 1.0, 0.0);
@@ -173,4 +177,5 @@
   uint64_t   *ippObjID    ; ALLOCATE (ippObjID    ,  uint64_t, Ndetections);
   uint64_t   *objID       ; ALLOCATE (objID       ,  uint64_t, Ndetections);
+  int        *photcode    ; ALLOCATE (photcode    ,  int,      Ndetections);
   uint32_t   *flags       ; ALLOCATE (flags       ,  uint32_t, Ndetections);
   float      *zp          ; ALLOCATE (zp          ,  float,    Ndetections);
@@ -190,4 +195,5 @@
     ippObjID[i]    = detections[i].ippObjID    ;
     objID[i]       = detections[i].objID       ;
+    photcode[i]    = detections[i].photcode    ;
     flags[i]       = detections[i].flags       ;
     zp[i]          = detections[i].zp          ;
@@ -207,4 +213,5 @@
   gfits_set_bintable_column (&theader, &ftable, "ippObjID",    ippObjID    , Ndetections);
   gfits_set_bintable_column (&theader, &ftable, "objID",       objID       , Ndetections);
+  gfits_set_bintable_column (&theader, &ftable, "photcode",    photcode    , Ndetections);
   gfits_set_bintable_column (&theader, &ftable, "flags",       flags       , Ndetections);
   gfits_set_bintable_column (&theader, &ftable, "zp",          zp          , Ndetections);
@@ -222,4 +229,5 @@
   free (ippObjID    );
   free (objID       );
+  free (photcode    );
   free (flags       );
   free (zp          );
Index: /trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
===================================================================
--- /trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c	(revision 35577)
+++ /trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c	(revision 35578)
@@ -49,4 +49,5 @@
       // detections[Ndetections]. ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID
       detections[Ndetections].objID	   = average->extID;   // objID
+      detections[Ndetections].photcode	   = measure->photcode;   // photcode
       detections[Ndetections].flags 	   = measure->dbFlags;  // flags
       detections[Ndetections].zp 	   = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal;   // zp
@@ -168,5 +169,5 @@
   }
 
-  PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n");
+  PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, photcode, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n");
 
   return TRUE;
@@ -179,25 +180,5 @@
 int insert_detections_mysql_value (IOBuffer *buffer, Average *average, Measure *measure) {
 
-  // XXX I am changing the def of ippObjID if I use the code below
   PhotCode *code = GetPhotcodebyCode(measure->photcode);
-  // PrintIOBuffer (buffer, "    (%d, %u, %lu, %lu, %lu, %u, %f, %f, %f, %f, %lf, %lf, %f, %f),\n",
-  // 		 measure->imageID,    // imageID
-  // 		 measure->detID,   // ippDetectID
-  // 		 measure->extID,   // detectID
-  // 		 ((uint64_t)average->catID * 1000000000) + (uint64_t)average->objID, // ippObjID
-  // 		 // NOTE: this is better, but the above is the current ippToPsps value
-  // 		 // ((uint64_t)average->catID << 32) + (uint64_t)average->objID, // ippObjID
-  // 		 average->extID,   // objID
-  // 		 measure->dbFlags,  // flags
-  // 		 code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal,   // zp
-  // 		 measure->dMcal,    // zpErr
-  // 		 measure->airmass,
-  // 		 pow(10.0, 0.4 * measure->dt),    // expTime
-  // 		 average->R - measure->dR / 3600.,    // ra
-  // 		 average->D - measure->dR / 3600.,    // dec
-  // 		 measure->dXccd * 0.01 * fabs(measure->pltscale), // estimate of raErr
-  // 		 measure->dYccd * 0.01 * fabs(measure->pltscale) // estimate of decErr
-  //   ); 
-  
   PrintIOBuffer (buffer, "(%d, ", measure->imageID);	  // imageID
   PrintIOBuffer (buffer, "%u, ", measure->detID); // ippDetectID
@@ -207,4 +188,5 @@
   // ((uint64_t)average->catID << 32) + (uint64_t)average->objID, // ippObjID
   PrintIOBuffer (buffer, "%lu, ", average->extID);	  // objID
+  PrintIOBuffer (buffer, "%d, ", measure->photcode);	  // photcode
   PrintIOBuffer (buffer, "%u, ", measure->dbFlags);	  // flags
 
