Changeset 19038 for trunk/ippTools/src/difftool.c
- Timestamp:
- Aug 12, 2008, 3:41:25 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r18976 r19038 598 598 PXOPT_COPY_S16(config->args, where, "-code", "fault", "=="); 599 599 600 psString query = pxDataGet("difftool_revertdiffskyfile.sql"); 601 if (!query) { 602 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 603 return false; 604 } 605 606 if (psListLength(where->list)) { 607 psString whereClause = psDBGenerateWhereConditionSQL(where, "diffSkyfile"); 608 psStringAppend(&query, " AND %s", whereClause); 609 psFree(whereClause); 610 } 600 if (!psDBTransaction(config->dbh)) { 601 psError(PS_ERR_UNKNOWN, false, "database error"); 602 psFree(where); 603 return false; 604 } 605 606 int num; // Number affected 607 608 // Update state to 'run' 609 { 610 psString query = pxDataGet("difftool_revertdiffskyfile_update.sql"); 611 if (!query) { 612 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 613 if (!psDBRollback(config->dbh)) { 614 psError(PS_ERR_UNKNOWN, false, "database error"); 615 } 616 return false; 617 } 618 619 if (psListLength(where->list)) { 620 psString whereClause = psDBGenerateWhereConditionSQL(where, "diffSkyfile"); 621 psStringAppend(&query, " AND %s", whereClause); 622 psFree(whereClause); 623 } 624 625 if (!p_psDBRunQuery(config->dbh, query)) { 626 psError(PS_ERR_UNKNOWN, false, "database error"); 627 psFree(query); 628 if (!psDBRollback(config->dbh)) { 629 psError(PS_ERR_UNKNOWN, false, "database error"); 630 } 631 return false; 632 } 633 psFree(query); 634 635 num = psDBAffectedRows(config->dbh); 636 637 if (num < 1) { 638 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 639 if (!psDBRollback(config->dbh)) { 640 psError(PS_ERR_UNKNOWN, false, "database error"); 641 } 642 return false; 643 } 644 } 645 646 // Delete product 647 { 648 psString query = pxDataGet("difftool_revertdiffskyfile_delete.sql"); 649 if (!query) { 650 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 651 if (!psDBRollback(config->dbh)) { 652 psError(PS_ERR_UNKNOWN, false, "database error"); 653 } 654 return false; 655 } 656 657 if (psListLength(where->list)) { 658 psString whereClause = psDBGenerateWhereConditionSQL(where, "diffSkyfile"); 659 psStringAppend(&query, " AND %s", whereClause); 660 psFree(whereClause); 661 } 662 663 if (!p_psDBRunQuery(config->dbh, query)) { 664 psError(PS_ERR_UNKNOWN, false, "database error"); 665 psFree(query); 666 if (!psDBRollback(config->dbh)) { 667 psError(PS_ERR_UNKNOWN, false, "database error"); 668 } 669 return false; 670 } 671 psFree(query); 672 673 if (psDBAffectedRows(config->dbh) != num) { 674 psError(PS_ERR_UNKNOWN, false, "Updated and deleted different number of entries!"); 675 if (!psDBRollback(config->dbh)) { 676 psError(PS_ERR_UNKNOWN, false, "database error"); 677 } 678 return false; 679 } 680 } 681 611 682 psFree(where); 612 683 613 if (!p_psDBRunQuery(config->dbh, query)) { 614 psError(PS_ERR_UNKNOWN, false, "database error"); 615 psFree(query); 616 return false; 617 } 618 psFree(query); 619 620 if (psDBAffectedRows(config->dbh) < 1) { 621 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 684 if (!psDBCommit(config->dbh)) { 685 psError(PS_ERR_UNKNOWN, false, "database error"); 622 686 return false; 623 687 }
Note:
See TracChangeset
for help on using the changeset viewer.
