IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 2, 2007, 2:08:14 PM (19 years ago)
Author:
jhoblitt
Message:

factor "large" sql statements out of camtool

File:
1 edited

Legend:

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

    r12188 r12189  
    9494    }
    9595
    96     psString query = psStringCopy(
    97             "SELECT"
    98             "   camPendingExp.*,"
    99             "   rawExp.camera,"
    100             "   rawExp.workdir"
    101             " FROM camPendingExp"
    102             " JOIN chipProcessedExp"
    103             "   USING(chip_id)"
    104             " JOIN rawExp"
    105             "   ON chipProcessedExp.exp_tag = rawExp.exp_tag"
    106             " LEFT JOIN camProcessedExp"
    107             "   on camPendingExp.cam_id = camPendingExp.cam_id"
    108             " LEFT JOIN camMask"
    109             "   ON camPendingExp.label = camMask.label"
    110             " WHERE"
    111             "   camProcessedExp.cam_id IS NULL"
    112             "   AND camMask.label IS NULL"
    113     );
     96    psString query = pxDataGet("camtool_find_pendingexp.sql");
     97    if (!query) {
     98        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     99        return false;
     100    }
    114101
    115102    if (config->where) {
     
    176163    PS_ASSERT_PTR_NON_NULL(config, false);
    177164
    178     psString query = psStringCopy(
    179             "SELECT"
    180             "   camPendingExp.cam_id,"
    181             "   chipProcessedImfile.*,"
    182             "   rawExp.camera,"
    183             "   rawExp.workdir"
    184             " FROM camPendingExp"
    185             " JOIN chipProcessedExp"
    186             "   USING(chip_id)"
    187             " JOIN chipProcessedImfile"
    188             "   USING(chip_id)"
    189             " JOIN rawExp"
    190             "   ON chipProcessedExp.exp_tag = rawExp.exp_tag"
    191             " LEFT JOIN camProcessedExp"
    192             "   ON camPendingExp.cam_id = camProcessedExp.cam_id"
    193             " LEFT JOIN camMask"
    194             "   ON camPendingExp.label = camMask.label"
    195             " WHERE"
    196             "   camProcessedExp.cam_id IS NULL"
    197             "   AND camMask.label IS NULL"
    198     );
     165    psString query = pxDataGet("camtool_find_pendingimfile.sql");
     166    if (!query) {
     167        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     168        return false;
     169    }
    199170
    200171    if (config->where) {
     
    238209    }
    239210
    240     if (!convertIdToStr(output)) {
    241         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    242         psFree(output);
    243         return false;
    244     }
    245 
    246     if (!convertIdToStr(output)) {
    247         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    248         psFree(output);
    249         return false;
    250     }
    251 
    252     if (!convertIdToStr(output)) {
    253         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    254         psFree(output);
    255         return false;
    256     }
    257 
    258211    // negate simple so the default is true
    259212    if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
     
    375328    }
    376329
    377     psString query = psStringCopy(
    378         "SELECT camPendingExp.*"
    379         " FROM camPendingExp"
    380         " LEFT JOIN camProcessedExp"
    381         "   USING(cam_id)"
    382         " WHERE"
    383         "   camProcessedExp.cam_id IS NULL"
    384         "   AND camPendingExp.cam_id = '%s'"
    385     );
     330    psString query = pxDataGet("camtool_find_pendingexp.sql");
     331    if (!query) {
     332        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     333        return false;
     334    }
    386335
    387336    if (!p_psDBRunQuery(config->dbh, query, cam_id)) {
     
    487436    }
    488437
    489     psString query = psStringCopy(
    490             "SELECT"
    491             "   camProcessedExp.*,"
    492             "   rawExp.camera,"
    493             "   rawExp.workdir"
    494             " FROM camProcessedExp"
    495             " JOIN chipProcessedExp"
    496             "   USING(chip_id)"
    497             " JOIN rawExp"
    498             "   chipProcessedExp.exp_tag = rawExp.exp_tag"
    499             " WHERE"
    500             "   camProcessedExp.cam_id IS NOT NULL" // bongus
    501     );
     438    psString query = pxDataGet("camtool_find_processedexp.sql");
     439    if (!query) {
     440        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     441        return false;
     442    }
    502443
    503444    if (config->where) {
     
    556497    }
    557498
    558     if (!convertIdToStr(output)) {
    559         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    560         psFree(output);
    561         return false;
    562     }
    563 
    564     if (!convertIdToStr(output)) {
    565         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    566         psFree(output);
    567         return false;
    568     }
    569 
    570     if (!convertIdToStr(output)) {
    571         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    572         psFree(output);
    573         return false;
    574     }
    575 
    576499    // negate simple so the default is true
    577500    if (!ippdbPrintMetadatas(stdout, output, "camProcessedExp", !simple)) {
Note: See TracChangeset for help on using the changeset viewer.