Changeset 16573
- Timestamp:
- Feb 21, 2008, 2:15:54 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080219/ippTools/src/pstamptool.c
r16471 r16573 108 108 109 109 psString lastFileset = psMetadataLookupStr(&status, config->args, "-last_fileset"); 110 psString state = psMetadataLookupStr(&status, config->args, "-state"); 111 if (!state) { 112 state = "enabled"; 113 } 110 114 111 115 if (!pstampDataStoreInsert(config->dbh, 112 116 0, 113 117 uri, 114 lastFileset 118 lastFileset, 119 state 115 120 )) { 116 121 psError(PS_ERR_UNKNOWN, false, "database error"); … … 182 187 return false; 183 188 } 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)) { 194 219 psError(PS_ERR_UNKNOWN, false, "database error"); 195 220 psFree(query);
Note:
See TracChangeset
for help on using the changeset viewer.
