// ============================================================================= // ============================================================================= int selecttpc() { // // Get values from TPC Table. This is either all values in the row or a single value. // if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField) << ";" << endl; else *seperateOutFile << dbq->getSqlSelectTpcRow(arguments.pSelectTagList.at(iTag)) << ";" << endl; } seperateOutFile->close(); delete seperateOutFile; return 1; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( arguments.pSelectSingleField == true ) { if ( fp->TpcTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in TPC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } for ( uint32_t iTag=0; iTaggetSqlSelectTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField)); Resultset rs = st.GetResultset(); int pos = fp->TpcTable->getPosition(arguments.pSelectField); while (rs.Next()) { if ( fp->TpcTable->isDate(pos) ) cout << arguments.pSelectField << " = " << rs.Get(1) << endl; else if ( fp->TpcTable->isString(pos) ) cout << arguments.pSelectField << " = " << rs.Get(1) << endl; else if ( fp->TpcTable->isNumber(pos) ) cout << arguments.pSelectField << " = " << rs.Get(1) << endl; } cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectTpcRow(arguments.pSelectTagList.at(iTag))); Resultset rs = st.GetResultset(); while (rs.Next()) { for ( uint32_t i=0; iTpcTable->getNcols(); i++ ) { cout << fp->TpcTable->getColName(i) << " : "; if (fp->TpcTable->isDate(i) ) cout << rs.Get(i+1) << endl; else if (fp->TpcTable->isString(i)) cout << rs.Get(i+1) << endl; else if (fp->TpcTable->isNumber(i)) cout << rs.Get(i+1) << endl; } } cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } delete fp; fp = 0; return 1; } // ============================================================================= // ============================================================================= int32_t selectpartition() { // // Get values for one partition. This is either all values in one row in the partition table or a single value. // if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectPartitionField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectField) << ";" << endl; } else { *seperateOutFile << dbq->getSqlSelectPartitionRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition)) << ";" << endl; } } } } } seperateOutFile->close(); delete seperateOutFile; return 1; } string query = ""; if ( arguments.pSelectSingleField == true ) { if ( arguments.pSelectField.compare("ON_PARTITION") != 0 ) { cerr << "*Error: Only column ON_PARTITION can be selected. Bad column name " << arguments.pSelectField << endl; return 0; } for ( uint32_t iTag=0; iTaggetSqlSelectPartitionField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectField); try { cout << "================================================================" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); while (rs.Next()) { cout << arguments.pSelectField << " = " << rs.Get(1) << endl; } cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectPartitionRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition)); try { cout.setf( ios::dec ); cout << "================================================================" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); FERODBFieldPositions *fp = new FERODBFieldPositions(); while (rs.Next()) { for ( int32_t i=0; iPartitionTable->getColName(i) << " = " << rs.Get(i+1) << endl; } } cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; delete fp; fp=0; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } return 1; } // ============================================================================= // ============================================================================= int32_t selectcru() { // // Get values from CRU table. This is either all values in one row in the CRU table or a single value. // if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectCruField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru), arguments.pSelectField) << ";" << endl; } else { *seperateOutFile << dbq->getSqlSelectCruRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru)) << ";" << endl; } } } } } } seperateOutFile->close(); delete seperateOutFile; return 1; } FERODBFieldPositions *fp = new FERODBFieldPositions(); string query = ""; if ( arguments.pSelectSingleField == true ) { 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; } for ( uint32_t iTag=0; iTaggetSqlSelectCruField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru), arguments.pSelectField); try { cout.setf( ios::dec ); cout << "================================================================" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ", cru " << arguments.pSelectCruList.at(iCru) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); while (rs.Next()) { if ( pos==38 ) { cout.setf( ios::dec ); cout << arguments.pSelectField << " = " << rs.Get(1) << endl; } else if ( pos>2 ) { cout.setf( ios::hex, ios::basefield ); cout << arguments.pSelectField << " = 0x" << rs.Get(1) << endl; } else { cout.setf( ios::dec ); cout << arguments.pSelectField << " = " << rs.Get(1) << endl; } } cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectCruRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru)); try { cout << "================================================================" << endl; cout.setf( ios::dec ); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ", cru " << arguments.pSelectCruList.at(iCru) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); while (rs.Next()) { for ( int32_t i=0; iCruTable->getColName(i) << " = " << rs.Get(i+1) << endl; } else if ( i>2 ) { cout.setf( ios::hex, ios::basefield ); cout << fp->CruTable->getColName(i) << " = 0x" << rs.Get(i+1) << endl; } else { cout.setf( ios::dec ); cout << fp->CruTable->getColName(i) << " = " << rs.Get(i+1) << endl; } } } cout.setf( ios::dec ); cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } } delete fp; fp = 0; return 1; } // ============================================================================= // ============================================================================= int32_t selectfec() { // // Get values from FEC table. This is either all values in one row in the FEC table or a single value. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectFecField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectField) << ";" << endl; } else { *seperateOutFile << dbq->getSqlSelectFecRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec)) << ";" << endl; } } } } } } } seperateOutFile->close(); delete seperateOutFile; delete fp; fp = 0; return 1; } string query = ""; if ( arguments.pSelectSingleField == true ) { int pos = fp->FecTable->getPosition(arguments.pSelectField); if ( pos < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in FEC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } for ( uint32_t iTag=0; iTaggetSqlSelectFecField(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectField); try { cout.setf( ios::dec ); cout << "================================================================" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ", branch " << arguments.pSelectBranchList.at(iBranch) << ", fec " << arguments.pSelectFecList.at(iFec) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); while (rs.Next()) { if (pos > 3) { cout.setf( ios::hex, ios::basefield ); cout << arguments.pSelectField << " = 0x" << rs.Get(1) << endl; } else { cout.setf( ios::dec ); cout << arguments.pSelectField << " = " << rs.Get(1) << endl; } } cout.setf( ios::dec ); cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectFecRow(arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec)); try { cout.setf( ios::dec ); cout << "================================================================" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ", branch " << arguments.pSelectBranchList.at(iBranch) << ", fec " << arguments.pSelectFecList.at(iFec) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); while (rs.Next()) { for ( int32_t i=0; i3) { cout.setf( ios::hex, ios::basefield ); cout << fp->FecTable->getColName(i) << " = 0x" << rs.Get(i+1) << endl; } else { cout.setf( ios::dec ); cout << fp->FecTable->getColName(i) << " = " << rs.Get(i+1) << endl; } } } cout.setf( ios::dec ); cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } } } delete fp; fp = 0; return 1; } // ============================================================================= // ============================================================================= int32_t selectUL(string tablename) { // // Get values from one of the UL tables. This is either all values in one row or a single value. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlSelectUlField(tablename, arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectField) << ";" << endl; } else { *seperateOutFile << dbq->getSqlSelectUlRow(tablename, arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec)) << ";" << endl; } } } } } } } } seperateOutFile->close(); delete seperateOutFile; delete fp; fp = 0; return 1; } string query = ""; if ( arguments.pSelectSingleField == true ) { 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; } for ( uint32_t iTag=0; iTaggetSqlSelectUlField(tablename, arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec), arguments.pSelectField); try { cout.setf( ios::dec ); cout << "================================================================" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ", cru " << arguments.pSelectCruList.at(iCru) << ", EP " << arguments.pSelectBranchList.at(iBranch) << ", link " << arguments.pSelectFecList.at(iFec) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); while (rs.Next()) { cout.setf( ios::dec ); if (pos > 2) { cout << arguments.pSelectField << " = " << rs.Get(1) << endl; } else { cout << arguments.pSelectField << " = " << rs.Get(1) << endl; } } cout.setf( ios::dec ); cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } } } } else { for ( uint32_t iTag=0; iTaggetSqlSelectUlRow(tablename, arguments.pSelectTagList.at(iTag), arguments.pSelectSideList.at(iSide), arguments.pSelectSectorList.at(iSec), arguments.pSelectPartitionList.at(iPartition), arguments.pSelectCruList.at(iCru), arguments.pSelectBranchList.at(iBranch), arguments.pSelectFecList.at(iFec)); try { cout.setf( ios::dec ); cout << "================================================================" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ", side " << arguments.pSelectSideList.at(iSide) << ", sector " << arguments.pSelectSectorList.at(iSec) << ", partition " << arguments.pSelectPartitionList.at(iPartition) << ", cru " << arguments.pSelectCruList.at(iCru) << ", EP " << arguments.pSelectBranchList.at(iBranch) << ", link " << arguments.pSelectFecList.at(iFec) << ":" << endl; Statement st(con); st.Execute(query); Resultset rs = st.GetResultset(); while (rs.Next()) { cout.setf( ios::dec ); for ( int32_t i=0; i 2) { cout << fp->UlTable->getColName(i) << " = " << rs.Get(i+1) << endl; } else { cout << fp->UlTable->getColName(i) << " = " << rs.Get(i+1) << endl; } } } cout.setf( ios::dec ); cout << "==================" << endl << "Total fetched rows : " << rs.GetCount() << endl; } catch(exception &ex) { cout << ex.what() << endl; return 0; } } } } } } } } } delete fp; fp = 0; return 1; }