IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9370 for trunk/ippTools/src


Ignore:
Timestamp:
Oct 6, 2006, 3:07:48 PM (20 years ago)
Author:
jhoblitt
Message:

implement -select

File:
1 edited

Legend:

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

    r9346 r9370  
    124124    PS_ASSERT_PTR_NON_NULL(config, false);
    125125
     126    psString query = psStringCopy(
     127        "SELECT detNormalizedImfile.*"
     128        " FROM detNormalizedImfile"
     129        " JOIN detRun"
     130        "   ON detNormalizedImfile.det_id = detRun.position"
     131        " JOIN detRunSummary"
     132        "   ON detNormalizedImfile.det_id = detRunSummary.det_id"
     133        "   AND detNormalizedImfile.iteration = detRunSummary.iteration"
     134        " WHERE"
     135        "   detRun.state = 'stop'"
     136        "   AND detRunSummary.accept = 1"
     137    );
     138
     139    if (config->where) {
     140        psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
     141        psStringAppend(&query, " AND %s", whereClause);
     142        psFree(whereClause);
     143    }
     144
     145    if (!p_psDBRunQuery(config->dbh, query)) {
     146        psError(PS_ERR_UNKNOWN, false, "database error");
     147        psFree(query);
     148        return false;
     149    }
     150    psFree(query);
     151
     152    psArray *output = p_psDBFetchResult(config->dbh);
     153    if (!output) {
     154        psError(PS_ERR_UNKNOWN, false, "database error");
     155        return false;
     156    }
     157    if (!psArrayLength(output)) {
     158        // XXX check psError here
     159        psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found");
     160        psFree(output)
     161        return true;
     162    }
     163
     164    bool simple = false;
     165    {
     166        bool status = false;
     167        simple = psMetadataLookupBool(&status, config->args, "-simple");
     168        if (!status) {
     169            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     170            return false;
     171        }
     172    }
     173
     174    // negative simple so the default is true
     175    if (!ippdbPrintMetadatas(stdout, output, "detNormalizedImfile", !simple)) {
     176        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     177        psFree(output);
     178        return false;
     179    }
     180
     181    psFree(output);
     182
    126183    return true;
    127184}
Note: See TracChangeset for help on using the changeset viewer.