Changeset 8107 for trunk/MagicSoft/Mars/datacenter/macros/insertdate.C
- Timestamp:
- 10/17/06 19:13:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/insertdate.C
r7460 r8107 45 45 #include <iostream> 46 46 #include <iomanip> 47 #include <fstream>48 47 49 48 #include <TEnv.h> 50 49 51 #include <MSQLServer.h> 52 #include <TSQLRow.h> 53 #include <TSQLResult.h> 50 #include <MSQLMagic.h> 54 51 55 52 using namespace std; 56 57 Bool_t ExistStr(MSQLServer &serv, const char *column, const char *table, const char *test)58 {59 TString query(Form("SELECT %s FROM %s WHERE %s='%s'", column, table, column, test));60 61 cout << "query: " << query << endl;62 63 TSQLResult *res = serv.Query(query);64 if (!res)65 return kFALSE;66 67 Bool_t rc = kFALSE;68 69 TSQLRow *row=res->Next();70 if (row && (*row)[0])71 rc=kTRUE;72 73 delete res;74 return rc;75 }76 77 53 78 54 int insertdate(TString date) … … 80 56 TEnv env("sql.rc"); 81 57 82 MSQL Serverserv(env);58 MSQLMagic serv(env); 83 59 if (!serv.IsConnected()) 84 60 { … … 94 70 //insert entry for date into the table SequenceBuildStatus, 95 71 // if entry is not yet existing 96 if (! ExistStr(serv,"fDate", "SequenceBuildStatus", date))72 if (!serv.ExistStr("fDate", "SequenceBuildStatus", date)) 97 73 { 98 TString query(Form("INSERT SequenceBuildStatus SET fDate='%s', fCCFilled=Now() ", 99 date.Data())); 74 TString vals(Form("fDate='%s', fCCFilled=Now()", date.Data())); 100 75 101 TSQLResult *res = serv.Query(query); 102 if (!res) 103 { 104 cout << "Error - could not insert entry" << endl; 105 return 0; 106 } 107 delete res; 76 const Int_t rc = serv.Insert("SequenceBuildStatus", vals); 77 if (rc==kFALSE) // Query failed 78 return -1; 79 //if (rc<0) // Dummy mode 80 // return 0; 108 81 } 109 82 else … … 111 84 cout << date << " already exists... do update. " << endl; 112 85 113 TString query="UPDATE SequenceBuildStatus SET fCCFilled=Now(), fExclusionsDone=NULL, "; 114 query +=Form("fSequenceEntriesBuilt=NULL WHERE fDate='%s' ", date.Data()); 86 const Int_t rc = serv.Update("SequenceBuildStatus", 87 "fCCFilled=Now(), fExclusionsDone=NULL, fSequenceEntriesBuilt=NULL", 88 Form("fDate='%s'", date.Data())); 115 89 116 TSQLResult *res = serv.Query(query); 117 if (!res) 118 { 119 cout << "Error - could not update entry" << endl; 120 return 0; 121 } 122 delete res; 90 if (rc==kFALSE) // Query failed 91 return -1; 92 //if (rc<0) // Dummy mode 93 // return 0; 94 123 95 } 124 96
Note:
See TracChangeset
for help on using the changeset viewer.