91 const std::string& writer_user,
const std::string& writer_password) {
93 if (head_id < 0)
return nullptr;
97 query->setRowCacheSize(1);
98 query->addToTableList(
"MDT_HEAD");
99 query->addToTableList(
"MDT_DATA_SCHEMA");
100 query->addToOutputList(
"MDT_DATA_SCHEMA.SCHEMA_NAME",
"SCHEMA");
101 query->addToOutputList(
"MDT_DATA_SCHEMA.WRITER_ACCOUNT",
"WRITER_ACCOUNT");
102 query->addToOutputList(
"MDT_DATA_SCHEMA.ACTIVE",
"ACTIVE");
103 query->addToOutputList(
"MDT_DATA_SCHEMA.ARCHIVED",
"ARCHIVED");
104 query->addToOutputList(
"MDT_DATA_SCHEMA.ARCHIVE_CONNECTION_STRING",
"ARCHIVE_CONNECTION_STRING");
105 std::string condition =
"MDT_HEAD.DATA_SCHEMA=MDT_DATA_SCHEMA.SCHEMA_NAME and MDT_HEAD.HEAD_ID=:hid";
106 coral::AttributeList conditionData;
107 conditionData.extend<
int>(
"hid");
108 conditionData[
"hid"].data<
int>() = head_id;
109 query->setCondition(condition, conditionData);
110 coral::ICursor& cursor =
query->execute();
111 if (!cursor.next()) {
113 log << MSG::WARNING <<
"No information about head_id=" << head_id <<
" found!" <<
endmsg;
116 const coral::AttributeList&
al = cursor.currentRow();
117 if (write && !
al[
"ACTIVE"].data<bool>()) {
119 log << MSG::WARNING <<
"Can only write to the active schema" <<
endmsg;
122 if (
al[
"ARCHIVED"].data<bool>()) {
123 return new CalibDbConnection(
al[
"ARCHIVE_CONNECTION_STRING"].data<std::string>(),
al[
"SCHEMA"].data<std::string>());
127 std::string user, passwd;
129 conn->SetLogin(user, passwd);
134 ret->
SetLogin(writer_user, writer_password);
136 }
catch (coral::SchemaException& e) {
138 log << MSG::WARNING <<
"Schema exception : " << e.what() <<
endmsg;