Changeset 30769 for trunk/ippTools/src/pubtool.c
- Timestamp:
- Mar 1, 2011, 11:14:07 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pubtool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pubtool.c
r30376 r30769 37 37 static bool addMode(pxConfig *config); 38 38 static bool revertMode(pxConfig *config); 39 static bool updaterunMode(pxConfig *config); 39 40 40 41 # define MODECASE(caseName, func) \ … … 63 64 MODECASE(PUBTOOL_MODE_ADD, addMode); 64 65 MODECASE(PUBTOOL_MODE_REVERT, revertMode); 66 MODECASE(PUBTOOL_MODE_UPDATERUN, updaterunMode); 65 67 default: 66 68 psAbort("invalid option (this should not happen)"); … … 459 461 } 460 462 463 static bool updaterunMode(pxConfig *config) 464 { 465 PS_ASSERT_PTR_NON_NULL(config, false); 466 467 psMetadata *where = psMetadataAlloc(); // WHERE conditions 468 PXOPT_COPY_S64(config->args, where, "-pub_id", "pub_id", "=="); 469 PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "=="); 470 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 471 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 472 PXOPT_COPY_STR(config->args, where, "-fault", "fault", "=="); 473 474 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 475 476 psString query = NULL; // Query to run 477 psStringAppend(&query, "UPDATE publishRun LEFT JOIN publishDone using(pub_id) SET state = '%s'", state); 478 479 if (psListLength(where->list)) { 480 psString clause = psDBGenerateWhereConditionSQL(where, NULL); 481 psStringAppend(&query, "\n WHERE %s", clause); 482 psFree(clause); 483 } else { 484 psError(PS_ERR_UNKNOWN, false, "select arguments are required"); 485 return false; 486 } 487 psFree(where); 488 489 if (!p_psDBRunQuery(config->dbh, query)) { 490 psError(PS_ERR_UNKNOWN, false, "Database error"); 491 psFree(query); 492 return false; 493 } 494 psFree(query); 495 496 long numUpdated = psDBAffectedRows(config->dbh); 497 psLogMsg("pubtool", PS_LOG_INFO, "%ld rows updated.", numUpdated); 498 499 return true; 500 }
Note:
See TracChangeset
for help on using the changeset viewer.
