20 #include "RelationalAccess/ITableDescription.h"
21 #include "RelationalAccess/IColumn.h"
88 const std::vector< std::string >& columnNames,
95 coral::ISchema&
schema = schemaName.empty() ?
99 coral::ITable&
table = schema.tableHandle( tableName ) ;
102 boost::shared_ptr< coral::IQuery >
query( table.newQuery() ) ;
105 std::vector< std::string >::const_iterator it = columnNames.begin() ;
106 std::vector< std::string >::const_iterator
end = columnNames.end() ;
107 for( ; it !=
end ; ++it )
109 query->addToOutputList( *it ) ;
113 if( !conditionLHS.empty() && conditionRHS.
numberRows() == 1 )
115 if( !conditionRHSName.empty() )
118 coral::AttributeList attList ;
119 attList.extend( conditionRHSName,
typeid(
std::string ) ) ;
122 attList[ conditionRHSName ].data<
std::string >() = tmp ;
124 query->setCondition( conditionLHS +
" = :" + conditionRHSName,
130 query->setCondition( conditionLHS +
" = :" +
136 coral::ICursor& cursor =
query->execute() ;
140 std::vector< coral::AttributeList > atts ;
141 while( cursor.next() )
143 atts.push_back( cursor.currentRow() ) ;
159 columnNames.push_back( columnName ) ;
160 return basicQuery( columnNames, schemaName, tableName,
161 conditionLHS, conditionRHS, conditionRHSName ) ;
164 std::vector< std::string >
169 coral::ISchema&
schema = schemaName.empty() ?
173 coral::ITable&
table = schema.tableHandle( tableName ) ;
174 const coral::ITableDescription& tableDesc = table.description() ;
176 std::vector< std::string >
names ;
177 int nCols = tableDesc.numberOfColumns() ;
179 for(
int i = 0 ;
i < nCols ; ++
i )
181 const coral::IColumn&
column = tableDesc.columnDescription(
i ) ;
182 names.push_back( column.name() ) ;
192 const std::vector< std::string >& columnNames,
199 coral::ISchema&
schema = schemaName.empty() ?
206 coral::IQuery*
query = schema.newQuery(); ;
209 for (std::vector<std::string>::const_iterator constIt = columnNames.begin(); constIt
210 != columnNames.end(); ++constIt) {
211 query->addToOutputList(*constIt);
214 query->addToTableList(viewName);
217 if (!conditionLHS.empty() && conditionRHS.
numberRows() == 1) {
219 if (!conditionRHSName.empty()) {
221 coral::AttributeList attList;
222 attList.extend(conditionRHSName,
typeid(
std::string));
225 attList[conditionRHSName].data<
std::string> () = tmp;
227 query->setCondition(conditionLHS +
" = :" + conditionRHSName, attList);
232 conditionLHS +
" = :" + conditionRHS.
columnNames().front(),
237 coral::ICursor& cursor = query->execute();
241 std::vector<coral::AttributeList> atts;
242 while (cursor.next()) {
243 atts.push_back(cursor.currentRow());
272 columnNames.push_back( columnName ) ;
273 return basicQuery( columnNames, schemaName, viewName,
274 conditionLHS, conditionRHS, conditionRHSName ) ;
277 std::vector< std::string >
282 coral::ISchema&
schema = schemaName.empty() ?
286 std::set< std::string > views = schema.listViews ();
287 std::vector< std::string >
names ;
289 if (schema.existsView (viewName)) {
291 coral::IView& view = schema.viewHandle( viewName ) ;
293 int nCols = view.numberOfColumns() ;
295 for (
int i = 0;
i < nCols; ++
i) {
296 const coral::IColumn&
column = view.column(
i);
297 names.push_back(column.name());
bool fillVariable(const std::string &columnName, T &outputVariable) const
static const HistoName names[]
DbTransaction & transaction()
std::vector< std::string > columnNamesView(const std::string &schemaName, const std::string &viewName) const
coral::ISchema & schema(const std::string &schemaName)
void connect(const std::string &connectString, const std::string &authenticationPath, bool isOMDS=false)
int start(bool readOnly=false)
start transaction
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
const std::vector< coral::AttributeList > & attributeLists() const
const std::vector< std::string > & columnNames() const
void connect(const std::string &connectString, const std::string &authenticationPath)
coral::ISchema & nominalSchema()
std::vector< std::vector< double > > tmp
std::vector< std::string > columnNames(const std::string &schemaName, const std::string &tableName) const
cond::DbSession * session
const QueryResults basicQueryView(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &viewName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const