18 size_t ipos = fToken.find (
"OID=");
19 if (ipos != std::string::npos) {
20 ipos = fToken.find (
'-', ipos);
21 if (ipos != std::string::npos) {
22 size_t ipos2 = fToken.find (
']', ipos);
23 if (ipos2 != std::string::npos) {
24 while (fToken [++ipos] !=
'0');
27 unsigned long result = strtoul (
id.c_str (), &endptr, 16);
28 if (endptr && !*endptr)
return long (result);
35 const char* getTable (
const HcalPedestals* fObject) {
return "HCALPEDESTAL";}
36 const char* getTable (
const HcalGains* fObject) {
return "HCALGAIN";}
42 mEnvironment = oracle::occi::Environment::createEnvironment (oracle::occi::Environment::OBJECT);
44 size_t ipass = fDb.find (
'/');
45 size_t ihost = fDb.find (
'@');
47 if (ipass == std::string::npos || ihost == std::string::npos) {
48 std::cerr <<
"HcalDbPoolOCCI::HcalDbPoolOCCI-> Error in connection string format: " << fDb
49 <<
" Expect user/password@db" << std::endl;
61 std::cerr <<
"HcalDbPoolOCCI::HcalDbPoolOCCI exception-> " << sqlExcp.getErrorCode () <<
": " << sqlExcp.what () << std::endl;
69 oracle::occi::Environment::terminateEnvironment (
mEnvironment);
92 if (
debug)
std::cout <<
"executing query: \n" << sql_query << std::endl;
96 while (rset->next ()) {
107 std::cerr <<
"HcalDbPoolOCCI::getMetadataToken exception-> " << sqlExcp.getErrorCode () <<
": " << sqlExcp.what () << std::endl;
114 long iovId = getObjectId (fIov);
116 char sql_query [1024];
117 sprintf (sql_query,
"select IOV_IOV_UNSIGNED_LONG, IOV_IOV_STRING from COND__IOV_IOV where ID_ID = %ld ORDER BY IOV_IOV_UNSIGNED_LONG DESC", iovId);
119 if (
debug)
std::cout <<
"executing query: \n" << sql_query << std::endl;
123 while (rset->next ()) {
124 unsigned long runMax = rset->getUInt (1);
126 if (fRun <= runMax) {
134 std::cerr <<
"HcalDbPoolOCCI::getDataToken exception-> " << sqlExcp.getErrorCode () <<
": " << sqlExcp.what () << std::endl;
140 template <
class T,
class S>
143 if (
debug)
std::cout <<
"HcalDbPoolOCCI::getObjectGeneric-> tag/token: " << fTag <<
'/' << mdToken << std::endl;
144 if (mdToken.empty ())
return false;
146 if (
debug)
std::cout <<
"HcalDbPoolOCCI::getObjectGeneric-> Run/token: " << fRun <<
'/' << objToken << std::endl;
147 if (objToken.empty ())
return false;
148 long id = getObjectId (objToken);
150 char sql_query [1024];
151 const char*
name = getTable (fObject);
152 sprintf (sql_query,
"select MITEMS_%s_MID, MITEMS_%s_MVALUE1, MITEMS_%s_MVALUE2, MITEMS_%s_MVALUE3, MITEMS_%s_MVALUE4 from %sS_MITEMS where ID_ID = %ld ORDER BY MITEMS_%s_MID",
153 name, name, name, name, name, name,
id, name);
155 if (
debug)
std::cout <<
"executing query: \n" << sql_query << std::endl;
159 while (rset->next ()) {
160 unsigned long hcalId = rset->getUInt (1);
162 for (
int i = 0;
i < 4;
i++) values [
i] = rset->getFloat (
i+2);
164 fCondObject =
new S(
DetId (hcalId), values[0], values[1], values[2], values[3]);
165 fObject->addValues (*fCondObject);
174 std::cerr <<
"HcalDbPoolOCCI::getObjectn exception-> " << sqlExcp.getErrorCode () <<
": " << sqlExcp.what () << std::endl;
std::string getDataToken(const std::string &fIov, unsigned long fRun)
bool getObject(HcalPedestals *fObject, const std::string &fTag, unsigned long fRun)
oracle::occi::SQLException SQLException
oracle::occi::Connection * mConnect
bool getObjectGeneric(T *fObject, S *fCondObject, const std::string &fTag, unsigned long fRun)
oracle::occi::Environment * mEnvironment
std::string getMetadataToken(const std::string &fTag)
oracle::occi::Statement * mStatement
oracle::occi::ResultSet ResultSet
HcalDbPoolOCCI(const std::string &fDb)