IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 21, 2007, 4:27:42 PM (19 years ago)
Author:
jhoblitt
Message:

pz*tool modernization efforts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pzgetimfiles.c

    r14023 r14600  
    274274            "       incoming.telescope,"
    275275            "       incoming.class,"
    276             "       incoming.class_id,"
    277             "       NULL" // exp_id, will be assigned later
     276            "       incoming.class_id"
    278277            "   FROM incoming"
    279278            "   JOIN pzPendingExp"
     
    367366    }
    368367
    369     // copy the summitExp row into newExp in order to create a new exp_id
    370     {
    371         psString exp_id = pxGenExpTag(config, filesetid);
    372         if (!exp_id) {
    373             // rollback
    374             if (!psDBRollback(config->dbh)) {
    375                 psError(PS_ERR_UNKNOWN, false, "database error");
    376             }
    377             psError(PS_ERR_UNKNOWN, false, "database error");
    378             return false;
    379         }
    380 
    381         char *query =
    382             "INSERT INTO newExp"
    383             "   SElECT"
    384             "       '%s'," // exp_id
    385             "       summitExp.exp_name,"
    386             "       summitExp.camera,"
    387             "       summitExp.telescope,"
    388             "       summitExp.dateobs,"
    389             "       summitExp.exp_type,"
    390             "       summitExp.imfiles,"
    391             "       0"      // error flags
    392             "   FROM summitExp"
    393             "   WHERE"
    394             "       summitExp.exp_name = '%s'"
    395             "       AND summitExp.camera = '%s'"
    396             "       AND summitExp.telescope = '%s'";
    397 
    398         if (!p_psDBRunQuery(config->dbh, query, exp_id, filesetid, camera, telescope)) {
    399             // rollback
    400             if (!psDBRollback(config->dbh)) {
    401                 psError(PS_ERR_UNKNOWN, false, "database error");
    402             }
    403             psError(PS_ERR_UNKNOWN, false, "database error");
    404             psFree(exp_id);
    405             return false;
    406         }
    407         psFree(exp_id);
    408 
    409         // sanity check: we should have inserted only one row
    410         psU64 affected = psDBAffectedRows(config->dbh);
    411         if (psDBAffectedRows(config->dbh) != 1) {
    412             // rollback
    413             if (!psDBRollback(config->dbh)) {
    414                 psError(PS_ERR_UNKNOWN, false, "database error");
    415             }
    416             psError(PS_ERR_UNKNOWN, false, "should have affected 1 row but %" PRIu64 " rows were modified", affected);
    417             return false;
    418         }
    419     }
    420  
    421     // set the exp_id for the imfiles (files) in the exposure (fileset) that
    422     // we are investigating
    423     {
    424         char *query =
    425             "UPDATE pzPendingImfile"
    426             " SET exp_id = (SELECT exp_id from newExp"
    427             "                WHERE exp_name = '%s'"
    428             "                AND camera = '%s'"
    429             "                AND telescope = '%s')"
    430             " WHERE"
    431             "   exp_name = '%s'"
    432             "   AND camera = '%s'"
    433             "   AND telescope = '%s'";
    434         if (!p_psDBRunQuery(config->dbh, query, filesetid, camera, telescope, filesetid, camera, telescope)) {
    435             // rollback
    436             if (!psDBRollback(config->dbh)) {
    437                 psError(PS_ERR_UNKNOWN, false, "database error");
    438             }
    439             psError(PS_ERR_UNKNOWN, false, "database error");
    440             return false;
    441         }
    442     }
    443 
    444368    // cp the pzPendingExp entry to pzDoneExp
    445369    {
Note: See TracChangeset for help on using the changeset viewer.