IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 1, 2009, 10:06:07 AM (17 years ago)
Author:
bills
Message:

add options to pstampJob move sql for -listjob to a sql file

File:
1 edited

Legend:

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

    r25558 r25711  
    544544    PXOPT_LOOKUP_S16(fault,       config->args, "-fault",      false, false);
    545545    PXOPT_LOOKUP_S64(exp_id,      config->args, "-exp_id",     false, false);
     546    PXOPT_LOOKUP_S64(options,     config->args, "-options",     false, false);
    546547
    547548    // unless the job is being inserted with stop state require outputBase
     
    568569            fault,
    569570            exp_id,
    570             outputBase
     571            outputBase,
     572            options
    571573            )) {
    572574        psError(PS_ERR_UNKNOWN, false, "database error");
     
    592594    PS_ASSERT_PTR_NON_NULL(config, false);
    593595
    594     PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", false, false);
    595     PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", false, false);
     596    psMetadata *where = psMetadataAlloc();
     597    PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "==");
     598    PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "==");
     599    PXOPT_COPY_S64(config->args, where, "-fault",  "fault", "==");
    596600
    597601    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    598602    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    599603
    600     psString query = NULL;
    601 
    602     if (!req_id && !job_id) {
    603         fprintf(stderr, "either req_id or job_id must be specified\n");
     604    if (!psListLength(where->list)) {
     605        fprintf(stderr, "search arguments are required\n");
    604606        exit (1);
    605607    }
    606608
    607     if (req_id) {
    608         psStringAppend(&query,
    609                 "SELECT"
    610                 " pstampJob.*, pstampRequest.name, pstampRequest.outProduct"
    611                 " FROM pstampJob"
    612                 " JOIN pstampRequest USING(req_id)"
    613                 " WHERE req_id = %" PRId64, req_id
    614             );
    615     } else {
    616         psStringAppend(&query,
    617                 "SELECT"
    618                 " pstampJob.*, pstampRequest.name, pstampRequest.outProduct"
    619                 " FROM pstampJob"
    620                 " JOIN pstampRequest USING(req_id)"
    621                 " WHERE job_id = %" PRId64, job_id
    622             );
    623     }
     609    psString query = pxDataGet("pstamptool_listjob.sql");
     610    if (!query) {
     611        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     612        return false;
     613    }
     614
     615    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
     616    if (psListLength(where->list)) {
     617        psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampJob");
     618        psStringAppend(&query, " WHERE %s", whereClause);
     619        psFree(whereClause);
     620    }
     621    psFree(where);
    624622
    625623    // treat limit == 0 as "no limit"
Note: See TracChangeset for help on using the changeset viewer.