// ============================================================================= // ============================================================================= int32_t updatecrubind() { // // Update a field for many CRUs all with the same value. Use bind variables. // FERODBFieldPositions *fp = new FERODBFieldPositions(); int pos = fp->CruTable->getPosition(arguments.pSelectField); if ( pos < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in CRU Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateCruField(arguments.pSelectField) << endl; seperateOutFile->close(); delete seperateOutFile; } else { int32_t ctr = 0; vector ivals; vector fvals; vector isides; vector isectors; vector ipartitions; vector icrus; try { int32_t pbsize = arguments.pSelectSideList.size()*arguments.pSelectSectorList.size()*arguments.pSelectPartitionList.size()*arguments.pSelectCruList.size(); sw->start(); Statement st(con); st.Prepare(dbq->getSqlBindUpdateCruField(arguments.pSelectTagList, arguments.pSelectField)); st.SetBindArraySize(pbsize); if ( pos==38 ) st.Bind(":1", fvals, BindInfo::In); else st.Bind(":1", ivals, BindInfo::In); st.Bind(":2", isides, BindInfo::In); st.Bind(":3", isectors, BindInfo::In); st.Bind(":4", ipartitions, BindInfo::In); st.Bind(":5", icrus, BindInfo::In); for ( uint32_t iSide=0; iSidegetSqlUpdateUpdated(arguments.pSelectTagList)); // Update these tags as updated sw->stop(); cout << "Updated CRU table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch (exception& ex) { cout << ex.what() << endl; } } // end if pTest return 1; } // ============================================================================= int32_t updatefecbind() { // // Update a field for many FECs all with the same value. Use bind variables. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->FecTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in FEC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateFecField(arguments.pSelectField) << endl; seperateOutFile->close(); delete seperateOutFile; } else { int32_t ctr = 0; vector ivals; vector isides; vector isectors; vector ipartitions; vector ibranches; vector ifecs; try { int32_t pbsize = arguments.pSelectSideList.size()*arguments.pSelectSectorList.size()*arguments.pSelectPartitionList.size(); pbsize *= arguments.pSelectBranchList.size()*arguments.pSelectFecList.size(); sw->start(); Statement st(con); st.Prepare(dbq->getSqlBindUpdateFecField(arguments.pSelectTagList, arguments.pSelectField)); st.SetBindArraySize(pbsize); st.Bind(":1", ivals, BindInfo::In); st.Bind(":2", isides, BindInfo::In); st.Bind(":3", isectors, BindInfo::In); st.Bind(":4", ipartitions, BindInfo::In); st.Bind(":5", ibranches, BindInfo::In); st.Bind(":6", ifecs, BindInfo::In); for ( uint32_t iSide=0; iSidegetSqlUpdateUpdated(arguments.pSelectTagList)); sw->stop(); cout << "Updated FEC table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch (exception& ex) { cout << ex.what() << endl; } } // end if pTest return 1; } // ============================================================================= int32_t updateULbind(string tablename) { // // Update a value for the given UL table. Use bind variables. // bool tableOfFloats = false; if ( tablename.compare("CMCORR") == 0 ) tableOfFloats = true; if ( tablename.compare("ITCORR1") == 0 ) tableOfFloats = true; if ( tablename.compare("ITCORR2") == 0 ) tableOfFloats = true; if ( tablename.compare("cmcorr") == 0 ) tableOfFloats = true; if ( tablename.compare("itcorr1") == 0 ) tableOfFloats = true; if ( tablename.compare("itcorr2") == 0 ) tableOfFloats = true; FERODBFieldPositions *fp = new FERODBFieldPositions(); int pos = fp->UlTable->getPosition(arguments.pSelectField); if ( pos < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in table " << tablename << " (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateUlField(tablename, arguments.pSelectField) << endl; seperateOutFile->close(); delete seperateOutFile; } else { int32_t ctr = 0; vector ivals; vector fvals; vector isides; vector isectors; vector ipartitions; vector icrus; vector ibranches; vector ifecs; try { int32_t pbsize = arguments.pSelectSideList.size()*arguments.pSelectSectorList.size()*arguments.pSelectPartitionList.size(); pbsize *= arguments.pSelectCruList.size()*arguments.pSelectBranchList.size()*arguments.pSelectFecList.size(); sw->start(); Statement st(con); st.Prepare(dbq->getSqlBindUpdateUlField(tablename, arguments.pSelectTagList, arguments.pSelectField)); st.SetBindArraySize(pbsize); if ( tableOfFloats && (pos>2) ) st.Bind(":1", fvals, BindInfo::In); else st.Bind(":1", ivals, BindInfo::In); st.Bind(":2", isides, BindInfo::In); st.Bind(":3", isectors, BindInfo::In); st.Bind(":4", ipartitions, BindInfo::In); st.Bind(":5", icrus, BindInfo::In); st.Bind(":6", ibranches, BindInfo::In); st.Bind(":7", ifecs, BindInfo::In); for ( uint32_t iSide=0; iSide2) ) fvals.push_back(arguments.pUpdateValueFloat); else ivals.push_back(arguments.pUpdateValueInt); isides.push_back(arguments.pSelectSideList.at(iSide)); // side isectors.push_back(arguments.pSelectSectorList.at(iSec)); // sector ipartitions.push_back(arguments.pSelectPartitionList.at(iPartition)); // partition icrus.push_back(arguments.pSelectCruList.at(iCru)); // cru ibranches.push_back(arguments.pSelectBranchList.at(iBranch)); // branch ifecs.push_back(arguments.pSelectFecList.at(iFec)); // fec } // end fec loop } // end branch loop } // end cru loop } // end partition loop } // end sector loop } // end side loop st.ExecutePrepared(); st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); sw->stop(); cout << "Updated UL table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch(exception &ex) { cout << ex.what() << endl; } } // end if pTest return 1; }