// ============================================================================= void createfunction(char *tablename) { if ( arguments.pTest ) { ofstream *outFile = new ofstream(); string filename = "CREATE_"; filename += tablename; filename += ".sql"; outFile->open(filename.c_str()); *outFile << dbq->getSqlCreateTable(tablename) << ";" << endl; outFile->close(); delete outFile; } else { if ( !tableExists(tablename) ) { try { Statement st(con); st.Execute(dbq->getSqlCreateTable(tablename)); } catch (exception &ex) { cout << ex.what() << endl; } cout << "*Table " << tablename << " created!" << endl; } else cout << "Table " << tablename << " exists! Nothing done!" << endl; } } // ============================================================================= // ============================================================================= int createtables() { // // Create Tables // int tmpCounter = 0; pb = new ProgressBar('=', 80, arguments.pCreateCounter, "Create Tables "); sw->start(); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("GBTX1") > 0) ) createfunction((char*)"GBTX1"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ITCORR1") > 0) ) createfunction((char*)"ITCORR1"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ITCORR2") > 0) ) createfunction((char*)"ITCORR2"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("CMCORR") > 0) ) createfunction((char*)"CMCORR"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ONCHANNEL") > 0) ) createfunction((char*)"ONCHANNEL"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ZSTHR") > 0) ) createfunction((char*)"ZSTHR"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("PEDESTAL") > 0) ) createfunction((char*)"PEDESTAL"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("CRU") > 0) ) createfunction((char*)"CRU"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("FEC") > 0) ) createfunction((char*)"FEC"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("PARTITION") > 0) ) createfunction((char*)"PARTITION"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("SECTOR") > 0) ) createfunction((char*)"SECTOR"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("TPC") > 0) ) createfunction((char*)"TPC"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("SECTOR_TPC") > 0) ) createfunction((char*)"SECTOR_TPC"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("PARTITION_SECTOR") > 0) ) createfunction((char*)"PARTITION_SECTOR"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("FEC_PARTITION") > 0) ) createfunction((char*)"FEC_PARTITION"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("CRU_PARTITION") > 0) ) createfunction((char*)"CRU_PARTITION"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("PEDESTAL_CRU") > 0) ) createfunction((char*)"PEDESTAL_CRU"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ZSTHR_CRU") > 0) ) createfunction((char*)"ZSTHR_CRU"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ONCHANNEL_CRU") > 0) ) createfunction((char*)"ONCHANNEL_CRU"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("CMCORR_CRU") > 0) ) createfunction((char*)"CMCORR_CRU"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ITCORR1_CRU") > 0) ) createfunction((char*)"ITCORR1_CRU"); if ( (arguments.pCreateList.count("ALL") > 0) || (arguments.pCreateList.count("ITCORR2_CRU") > 0) ) createfunction((char*)"ITCORR2_CRU"); sw->stop(); delete pb; cout << "Create Tables | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; return 1; } // ============================================================================= // ============================================================================= int showtables() { // // Show Tables // try { Statement st(con); st.Execute(dbq->getSqlQueryShowTables()); Resultset rs = st.GetResultset(); cout << "=== Tables in DB: "<< endl; while (rs.Next()) cout << rs.Get(1) << endl; } catch (exception &ex) { cout << ex.what() << endl; } return 1; }