IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 19, 2008, 10:41:00 AM (18 years ago)
Author:
bills
Message:

having status for a column name causes build issues. change to result.
Also changes to the pstampDataStore table.

File:
1 edited

Legend:

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

    r16471 r16544  
    108108
    109109    psString lastFileset = psMetadataLookupStr(&status, config->args, "-last_fileset");
     110    psString state = psMetadataLookupStr(&status, config->args, "-state");
     111    if (!state) {
     112        state = "enabled";
     113    }
    110114
    111115    if (!pstampDataStoreInsert(config->dbh,
    112116            0,
    113117            uri,
    114             lastFileset
     118            lastFileset,
     119            state
    115120        )) {
    116121        psError(PS_ERR_UNKNOWN, false, "database error");
     
    182187        return false;
    183188    }
    184     if (!lastFileset) {
    185         psError(PS_ERR_UNKNOWN, true, "-last_fileset is required");
    186         return false;
    187     }
    188 
    189     char *query ="UPDATE pstampDataStore"
    190                  " SET lastFileset = '%s'"
    191                  " WHERE ds_id = '%s'";
    192 
    193     if (!p_psDBRunQuery(config->dbh, query, lastFileset, ds_id)) {
     189    psString state = psMetadataLookupStr(&status, config->args, "-state");
     190    if (!status) {
     191        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
     192        return false;
     193    }
     194
     195    if (!state && !lastFileset) {
     196        psError(PS_ERR_UNKNOWN, true, "one of -last_fileset or -state is required");
     197        return false;
     198    }
     199
     200    char *query = NULL;
     201    bool needComma = false;
     202   
     203    psStringAppend(&query, "UPDATE pstampDataStore SET");
     204
     205    if (lastFileset) {
     206        psStringAppend(&query, " lastFileset = '%s'", lastFileset);
     207        needComma = true;
     208    }
     209
     210    if (state) {
     211        psStringAppend(&query, "%s state = '%s'", needComma ? "," : " ",
     212            state);
     213        needComma = true; // be ready in case we add another field
     214    }
     215               
     216    psStringAppend(&query, " WHERE ds_id = '%s'", ds_id);
     217
     218    if (!p_psDBRunQuery(config->dbh, query)) {
    194219        psError(PS_ERR_UNKNOWN, false, "database error");
    195220        psFree(query);
Note: See TracChangeset for help on using the changeset viewer.