// ============================================================================= void deletefunction(char *tablename) { if ( arguments.pTest == false ) { if ( tableExists(tablename) ) db->executeUpdate(dbq->getSqlDeleteTable(tablename)); } else { ofstream *seperateOutFile = new ofstream(); string filename = tablename; filename += ".sql"; seperateOutFile->open(filename.c_str()); *seperateOutFile << dbq->getSqlDeleteTable(tablename) << ";" << endl; seperateOutFile->close(); delete seperateOutFile; } } // ============================================================================= // ============================================================================= int deletetables() { // // Delete Tables // cout << "?????????????????????????????????????????????????????????" << endl; cout << "Are you sure you want to delete the selected tables? [y/n]" << endl; cout << "?????????????????????????????????????????????????????????" << endl; if ( getchar() != 'y' ) return 1; int tmpCounter = 0; pb = new ProgressBar('=', 80, arguments.pDropCounter, "Delete Tables"); sw->start(); try { // Drop View /* if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEESERVICES") > 0) ) { if ( arguments.pTest == false ) { if ( tableExists("FEESERVICES") ) db->executeUpdate(dbq->getSqlDropView("FEESERVICES")); } else { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("FEESERVICES.sql"); *seperateOutFile << dbq->getSqlDropView("FEESERVICES") << ";" << endl; seperateOutFile->close(); delete seperateOutFile; } pb->print(tmpCounter++); } */ // Drop View /* if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEE") > 0) ) { if ( arguments.pTest == false ) { if ( tableExists("FEE") ) db->executeUpdate(dbq->getSqlDropView("FEE")); } else { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("FEE.sql"); *seperateOutFile << dbq->getSqlDropView("FEE") << ";" << endl; seperateOutFile->close(); delete seperateOutFile; } pb->print(tmpCounter++); } */ if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("ALTRO_FEC") > 0) ) { deletefunction((char*)"ALTRO_FEC"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEC_RCU") > 0) ) { deletefunction((char*)"FEC_RCU"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("RCU_SECTOR") > 0) ) { deletefunction((char*)"RCU_SECTOR"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("SECTOR_TPC") > 0) ) { deletefunction((char*)"SECTOR_TPC"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("TPC") > 0) ) { deletefunction((char*)"TPC"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("SECTOR") > 0) ) { deletefunction((char*)"SECTOR"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("RCU") > 0) ) { deletefunction((char*)"RCU"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEC") > 0) ) { deletefunction((char*)"FEC"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("ALTRO") > 0) ) { deletefunction((char*)"ALTRO"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEE_A") > 0) ) { deletefunction((char*)"FEE_A"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEE_C") > 0) ) { deletefunction((char*)"FEE_C"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEESERVICES_A") > 0) ) { deletefunction((char*)"FEESERVICES_A"); pb->print(tmpCounter++); } if ( (arguments.pDeleteList.count("ALL") > 0) || (arguments.pDeleteList.count("FEESERVICES_C") > 0) ) { deletefunction((char*)"FEESERVICES_C"); pb->print(tmpCounter++); } } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } sw->stop(); delete pb; cout << "Delete Table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; return 1; }