4 #include "CoralBase/Attribute.h"
5 #include "CoralBase/Blob.h"
6 #include "RelationalAccess/ISchema.h"
7 #include "RelationalAccess/ITable.h"
8 #include "RelationalAccess/ITableDataEditor.h"
9 #include "RelationalAccess/IBulkOperation.h"
10 #include "RelationalAccess/IQuery.h"
11 #include "RelationalAccess/ICursor.h"
16 const coral::AttributeList&
data){
19 for(coral::AttributeList::const_iterator iAttr = data.begin();
20 iAttr!=data.end() && (ret==-1); ++iAttr){
21 if( iAttr->specification().name() == attributeName ) ret = index;
28 static char* cond[ 5 ] = { (
char*)
"=",(
char*)
">",(
char*)
"<",(
char*)
">=",(
char*)
"<=" };
29 return cond[ condType ];
46 m_data.extend<
int>( columnName );
47 index = m_data.size()-1;
48 if(!m_setClause.empty()) m_setClause +=
", ";
49 m_setClause += ( columnName +
"= :"+columnName );
55 const std::type_info& columnType ){
58 m_data.extend( columnName, columnType );
59 index = m_data.size()-1;
60 if(!m_setClause.empty()) m_setClause +=
", ";
61 m_setClause += ( columnName +
"= :"+columnName );
69 m_data.extend<coral::Blob>( columnName );
70 index = m_data.size()-1;
71 if(!m_setClause.empty()) m_setClause +=
", ";
72 m_setClause += ( columnName +
"= :"+columnName );
80 m_data.extend<
int>( columnName );
81 index = m_data.size()-1;
83 if(!m_whereClause.empty()) m_whereClause +=
" AND ";
84 m_whereClause += ( columnName +
"= :"+columnName );
91 m_data.extend<
int>( columnName );
92 index = m_data.size()-1;
93 if(!m_whereClause.empty()) m_whereClause +=
" AND ";
94 m_whereClause += ( columnName +
conditionOfType(condType)+
" :"+columnName );
113 return m_whereClause;
119 m_tableName( tableName ),
132 coral::ITable&
table = m_schema.tableHandle( m_tableName );
133 table.dataEditor().insertRow(
data() );
143 m_tableName( tableName ),
149 for( std::vector<coral::IBulkOperation*>::iterator iB = m_bulkOperations.begin();
150 iB != m_bulkOperations.end(); ++iB ){
156 coral::ITable&
table = m_schema.tableHandle( m_tableName );
158 m_bulkOperations.push_back( table.dataEditor().bulkInsert(
data(), rowCacheSize ) );
159 return *m_bulkOperations.back();
168 for( std::vector<coral::IBulkOperation*>::iterator iB = m_bulkOperations.begin();
169 iB != m_bulkOperations.end(); ++iB ){
173 m_bulkOperations.clear();
178 for( std::vector<coral::IBulkOperation*>::iterator iB = m_bulkOperations.begin();
179 iB != m_bulkOperations.end(); ++iB ){
182 m_bulkOperations.clear();
188 m_tableName( tableName ),
202 if( updateClause().
size() && whereClause().
size() ){
203 coral::ITable&
table = m_schema.tableHandle( m_tableName );
204 long nr = table.dataEditor().updateRows( updateClause(), whereClause(),
data() );
216 m_tableName( tableName ),
230 if( whereClause().
size() ){
231 coral::ITable&
table = m_schema.tableHandle( m_tableName );
232 long nr = table.dataEditor().deleteRows( whereClause(), whereData() );
243 m_spec( new coral::AttributeListSpecification ),
249 m_tableName( tableName ),
258 m_orderByCols.push_back( columnName );
264 ret = m_cursor->next();
276 int idx = m_spec->index( columnName );
278 m_spec->extend<
int >( columnName );
279 idx = m_spec->size()-1;
285 const std::type_info& columnType ){
286 int idx = m_spec->index( columnName );
288 m_spec->extend( columnName, columnType );
289 idx = m_spec->size()-1;
295 int idx = m_spec->index( columnName );
297 m_spec->extend<coral::Blob>( columnName );
298 idx = m_spec->size()-1;
306 m_whereData.extend<
int>( columnName );
307 index = m_whereData.size()-1;
308 if(!m_whereClause.empty()) m_whereClause +=
" AND ";
309 m_whereClause += ( columnName +
"= :"+columnName );
315 if(!m_cursor)
throwException(
"Query on table "+m_tableName+
" has not been executed.",
316 "ora::ReadOperation::data" );
317 return const_cast<coral::AttributeList&
>(m_cursor->currentRow());
325 return m_whereClause;
330 coral::ITable&
table = m_schema.tableHandle( m_tableName );
331 m_query.reset( table.newQuery() );
332 for ( coral::AttributeListSpecification::const_iterator iSpec = m_spec->begin();
333 iSpec != m_spec->end(); ++iSpec ) {
334 m_query->addToOutputList( iSpec->name() );
335 m_query->defineOutputType( iSpec->name(),iSpec->typeName());
337 for(std::vector<std::string>::iterator iCol = m_orderByCols.begin();
338 iCol != m_orderByCols.end(); iCol++ ){
339 m_query->addToOrderList( *iCol );
341 m_query->setCondition( m_whereClause, m_whereData );
342 m_query->setRowCacheSize( 100 );
343 m_cursor = &m_query->execute();
char * conditionOfType(ConditionType condType)
coral::AttributeListSpecification & attributeListSpecification()
int addData(const std::string &columnName, const std::type_info &columnType)
UpdateOperation(const std::string &tableName, coral::ISchema &schema)
BulkInsertOperation(const std::string &tableName, coral::ISchema &schema)
SelectOperation(const std::string &tableName, coral::ISchema &schema)
InsertOperation(const std::string &tableName, coral::ISchema &schema)
int addWhereId(const std::string &columnName)
coral::IBulkOperation & setUp(int rowCacheSize)
std::string & whereClause()
DeleteOperation(const std::string &tableName, coral::ISchema &schema)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
coral::AttributeList & data()
int addId(const std::string &columnName)
void addOrderId(const std::string &columnName)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
coral::AttributeList & whereData()
char data[epos_bytes_allocation]
int existAttribute(const std::string &attributeName, const coral::AttributeList &data)
void throwException(const std::string &message, const std::string &methodName)
int addBlobData(const std::string &columnName)
tuple size
Write out results.