17 void table_reupload(
const char* fDbName = 0,
const char* fTableName = 0,
const char* fFlavorName =
"ofl",
18 const char* fRequestTimestamp =
"2011-01-01 00:00:00",
19 const char* fStoreTimestamp =
"2012-01-01 00:00:00" ) {
28 if (!fDbName || !fTableName || !fFlavorName || !fRequestTimestamp || ! fStoreTimestamp) {
29 std::cerr <<
"ERROR: Missing initialization data, please check input parameters!\n";
33 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
39 gSystem->Load(
"St_base.so");
40 gSystem->Load(
"libStDb_Tables.so");
41 gSystem->Load(
"StDbLib.so");
47 StDbTable* dbtable = node->addDbTable(fTableName);
51 mgr->setRequestTime(fRequestTimestamp);
52 mgr->fetchDbTable(dbtable);
55 std::cout <<
"READ CHECK: " << dbtable->printCstructName() <<
" has data: " << (dbtable->hasData() ?
"yes" :
"no") <<
" (" << dbtable->GetNRows() <<
" rows)" << std::endl;
57 if (!dbtable->hasData()) {
58 std::cout <<
"ERROR: This table has no data to reupload. Please try some other timestamp!";
64 std::cout <<
"ATTENTION: please confirm that you want to reupload " << fDbName <<
" / " << fTableName <<
", " << fRequestTimestamp <<
" data with " << fStoreTimestamp <<
" timestamp.\n Type YES to proceed: ";
65 std::cin.getline(confirm,256);
67 if (test_cnf !=
"YES") {
68 std::cout <<
"since you've typed \"" << test_cnf <<
"\" and not \"YES\", data won't be reuploaded." << std::endl;
73 if (dbtable->hasData()) {
74 mgr->setStoreTime(fStoreTimestamp);
75 if (mgr->storeDbTable(dbtable)) {
76 std::cout <<
"SUCCESS: Data reupload complete for " << fDbName <<
" / " << fTableName <<
" [ flavor : " << fFlavorName <<
" ]"
77 <<
"\n" <<
"Data copied FROM " << fRequestTimestamp <<
" TO " << fStoreTimestamp << std::endl << std::endl;
79 std::cerr <<
"ERROR: Something went wrong. Please send error message text to DB Admin!" << std::endl;
static StDbManager * Instance()
strdup(..) is not ANSI