46{
48 m_accessSvc->msg() << MSG::WARNING <<
"RDBQuery cannot be executed more than once! Query: "
53 return;
54 }
55
61 }
62
64 m_accessSvc->msg() << MSG::ERROR <<
"Cannot connect to the database: "
66 throw std::runtime_error(
"Cannot connect to the database " +
m_connName);
67 }
68
70 try {
71
73 for (char& ch : upperName) {
74 ch = std::toupper (
static_cast<unsigned int>(ch));
75 }
76
77
80
81
83
84 for(
unsigned int i=0;
i<
m_fields.size(); ++
i) {
86 }
87 }
88 else {
89
90 const coral::ITableDescription& dataTableDesc =
m_accessSvc->getSession(
m_connName)->nominalSchema().tableHandle(upperName +
"_DATA").description();
91 for(
int i=0;
i<dataTableDesc.numberOfColumns(); ++
i) {
92 m_query->addToOutputList(upperName+
"_DATA."+dataTableDesc.columnDescription(i).name());
93 }
94 }
95
96 m_queryCount->addToOutputList(
"COUNT("+upperName+
"_DATA_ID)",
"SUMREC");
97
98
99 m_query->addToTableList(upperName +
"_DATA");
100 m_query->addToTableList(upperName +
"_DATA2TAG");
101
103
104
106 m_query->addToOrderList(upperName +
"_DATA." + upperName +
"_DATA_ID");
107 }
108 else {
110 }
111
112
114 bindsData.extend<std::string>("tagID");
115
116 std::string queryStructCondition = upperName +"_DATA2TAG." + upperName + "_TAG_ID =:tagID";
117 m_queryCount->setCondition(queryStructCondition , bindsData);
118
119 queryStructCondition += " AND " + upperName +"_DATA." + upperName + "_DATA_ID=" + upperName + "_DATA2TAG." + upperName + "_DATA_ID";
120 m_query->setCondition(queryStructCondition , bindsData);
121
122 bindsData[0].data<std::string>() =
m_tagId;
123
125 m_query->setMemoryCacheSize(1);
126
127
129 while(cursorCount.next()) {
130
131 m_size = cursorCount.currentRow()[
"SUMREC"].data<
long>();
132 }
133
134
136 return;
137 }
138 catch(coral::SchemaException& se) {
139 m_accessSvc->msg() << MSG::WARNING <<
"QUERY: Schema Exception : " + std::string(
se.what()) <<
endmsg;
140 }
141 catch(std::exception& e) {
142 m_accessSvc->msg() << MSG::WARNING <<
"QUERY: Exception : " + std::string(
e.what()) <<
endmsg;
143 }
144 catch(...) {
146 }
147
149}
#define ATLAS_THREAD_SAFE
std::unique_ptr< coral::IQuery > m_query
std::unique_ptr< coral::IQuery > m_queryCount