Changeset 8268 for trunk/ippTools/src/regtool.c
- Timestamp:
- Aug 9, 2006, 7:39:42 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/regtool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/regtool.c
r8250 r8268 167 167 PS_ASSERT_PTR_NON_NULL(config, false); 168 168 169 // make sure that the exp_id(s) are ready to be updated based on the same 170 // critera used in pendingexpMode 171 char *query = 172 "SELECT newImfile.* FROM newImfile" 173 " LEFT JOIN newExp USING(exp_id)" 174 " LEFT JOIN rawScienceExp USING(exp_id)" 175 " LEFT JOIN rawDetrendExp USING (exp_id)" 176 " WHERE newExp.exp_id is NOT NULL" 177 " AND rawScienceExp.exp_id IS NULL" 178 " AND rawDetrendExp.exp_id IS NULL"; 179 169 // make sure that the exp_id(s) are ready to be updated based on: 170 // exp_id is not in rawScienceExp 171 // exp_id is not in rawDetrendExp 172 // exp_id is not in newImfile 173 // that the correct count of imfiles is in rawImfile 174 psString query = psStringCopy("SELECT newExp.* FROM newExp LEFT JOIN newImfile USING(exp_id) LEFT JOIN rawScienceExp USING(exp_id) LEFT JOIN rawDetrendExp USING(exp_id) WHERE newExp.exp_id IS NOT NULL AND newImfile.exp_id IS NULL AND rawScienceExp.exp_id IS NULL AND newExp.imfiles = (SELECT COUNT(exp_id) FROM rawImfile GROUP BY exp_id)"); 175 176 { 177 bool status = false; 178 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); 179 if (!status) { 180 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 181 return false; 182 } 183 if (exp_id) { 184 psStringAppend(&query, " AND newExp.exp_id = '%s'", exp_id); 185 } 186 } 187 180 188 if (!p_psDBRunQuery(config->dbh, query)) { 181 189 psError(PS_ERR_UNKNOWN, false, "database error"); … … 293 301 newImfileRow *object = newImfileObjectFromMetadata(newImfiles->data[i]); 294 302 rawImfileRow *imfile = newToRawImfile(config, object); 295 psFree(object);296 303 if (!imfile) { 297 304 // rollback … … 300 307 } 301 308 psError(PS_ERR_UNKNOWN, false, "failed to create a new rawImfile row"); 309 psFree(object); 302 310 psFree(newImfiles); 303 311 return false; … … 310 318 psError(PS_ERR_UNKNOWN, false, "failed to insert row into the database"); 311 319 psFree(imfile); 320 psFree(object); 312 321 psFree(newImfiles); 313 322 return false; 314 323 } 315 324 psFree(imfile); 325 if (!newImfileDeleteObject(config->dbh, object)) { 326 // rollback 327 if (!psDBRollback(config->dbh)) { 328 psError(PS_ERR_UNKNOWN, false, "database error"); 329 } 330 psError(PS_ERR_UNKNOWN, false, "failed to delete row from the database"); 331 psFree(object); 332 psFree(newImfiles); 333 return false; 334 } 335 psFree(object); 316 336 } 317 337
Note:
See TracChangeset
for help on using the changeset viewer.
