Changeset 19107


Ignore:
Timestamp:
07/31/18 14:53:03 (6 years ago)
Author:
tbretz
Message:
Implmented ignore-errors option.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/calcsource.cc

    r19106 r19107  
    3030        ("table.source",   var<string>("Source"),     "Name of the table where the sources are stored")
    3131        ("table.position", var<string>("Position"),   "Name of the table where the calculated posiiton will be stored")
     32        ("ignore-errors",  po_switch(),               "Adds the IGNORE keyword to the INSERT query (turns errors into warnings, ignores rows with errors)")
    3233        ("force",          po_switch(),               "Force processing even if there is no database connection")
    3334        ("drop",           po_switch(),               "Drop the table (implies create)")
     
    104105        "The --create option is compatible with that. The --drop option is ignored.\n"
    105106        "\n"
    106         ""
     107        "To avoid failure in case an entry does already exist, you can add the IGNORE "
     108        "keyword to the INSERT query by --ignore-errors, which essentially ignores "
     109        "all errors and turns them into warnings which are printed after the query "
     110        "succeeded.\n"
     111        "\n"
    107112        "\n"
    108113        "For debugging purposes several print options and options to avoid irreversible "
     
    154159    const string   tab_source   = conf.Get<string>("table.source");
    155160    const string   tab_position = conf.Get<string>("table.position");
     161
     162    const bool ignore_errors    = conf.Get<bool>("ignore-errors");
    156163
    157164    const uint32_t file         = conf.Get<uint32_t>("file");
     
    596603            cout << "Inserting data into table " << tab_position << "." << endl;
    597604
    598         const string query2 =
    599             "INSERT `"+tab_position+"` (FileId, EvtNumber, X, Y) VALUES\n"+
     605        string query2 = "INSERT ";
     606        if (ignore_errors)
     607            query2 += "IGNORE ";
     608        query2 += "`"+tab_position+"` (FileId, EvtNumber, X, Y) VALUES\n"+
    600609            ins.str().substr(0, ins.str().size()-2)+
    601610            "\n";
Note: See TracChangeset for help on using the changeset viewer.