Changeset 14600 for trunk/ippTools/src/pzgetimfiles.c
- Timestamp:
- Aug 21, 2007, 4:27:42 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pzgetimfiles.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pzgetimfiles.c
r14023 r14600 274 274 " incoming.telescope," 275 275 " incoming.class," 276 " incoming.class_id," 277 " NULL" // exp_id, will be assigned later 276 " incoming.class_id" 278 277 " FROM incoming" 279 278 " JOIN pzPendingExp" … … 367 366 } 368 367 369 // copy the summitExp row into newExp in order to create a new exp_id370 {371 psString exp_id = pxGenExpTag(config, filesetid);372 if (!exp_id) {373 // rollback374 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_id385 " summitExp.exp_name,"386 " summitExp.camera,"387 " summitExp.telescope,"388 " summitExp.dateobs,"389 " summitExp.exp_type,"390 " summitExp.imfiles,"391 " 0" // error flags392 " 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 // rollback400 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 row410 psU64 affected = psDBAffectedRows(config->dbh);411 if (psDBAffectedRows(config->dbh) != 1) {412 // rollback413 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) that422 // we are investigating423 {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 // rollback436 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 444 368 // cp the pzPendingExp entry to pzDoneExp 445 369 {
Note:
See TracChangeset
for help on using the changeset viewer.
