#include <OraDatabaseSchema.h>
Public Member Functions | |
bool | add (const std::string &sequenceName) |
void | create () |
void | drop () |
void | erase (const std::string &sequenceName) |
bool | exists () |
bool | getLastId (const std::string &sequenceName, int &lastId) |
std::string | name () |
OraSequenceTable (coral::ISchema &dbSchema) | |
OraSequenceTable (const std::string &tableName, coral::ISchema &dbSchema) | |
void | sinchronize (const std::string &sequenceName, int lastValue) |
virtual | ~OraSequenceTable () |
Static Public Member Functions | |
static std::string | sequenceNameColumn () |
static std::string | sequenceValueColumn () |
static std::string | tableName () |
Private Attributes | |
std::string | m_tableName |
Definition at line 30 of file OraDatabaseSchema.h.
ora::OraSequenceTable::OraSequenceTable | ( | coral::ISchema & | dbSchema | ) | [explicit] |
Definition at line 129 of file OraDatabaseSchema.cc.
: ISequenceTable( schema), m_tableName( tableName() ){ }
ora::OraSequenceTable::OraSequenceTable | ( | const std::string & | tableName, |
coral::ISchema & | dbSchema | ||
) |
Definition at line 134 of file OraDatabaseSchema.cc.
: ISequenceTable( schema), m_tableName( tname ){ }
ora::OraSequenceTable::~OraSequenceTable | ( | ) | [virtual] |
Definition at line 140 of file OraDatabaseSchema.cc.
{ }
bool ora::OraSequenceTable::add | ( | const std::string & | sequenceName | ) | [virtual] |
Implements ora::ISequenceTable.
Definition at line 144 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, and python::IdGenerator::schema.
{ // Create the entry in the table coral::AttributeList insertData; insertData.extend<std::string>(sequenceNameColumn()); insertData.extend<int>(sequenceValueColumn()); coral::AttributeList::iterator iAttribute = insertData.begin(); iAttribute->data< std::string >() = sequenceName; ++iAttribute; iAttribute->data< int >() = -1; schema().tableHandle( name() ).dataEditor().insertRow( insertData ); return true; }
void ora::OraSequenceTable::create | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 209 of file OraDatabaseSchema.cc.
References idDealer::description, mergeVDriftHistosByStation::name, python::IdGenerator::schema, and ora::throwException().
{ if( schema().existsTable( name() )){ throwException( "ORA database sequence table already exists in this schema.", "OraSequenceTable::create"); } coral::TableDescription description( "OraDb" ); description.setName( name() ); description.insertColumn( sequenceNameColumn(), coral::AttributeSpecification::typeNameForType<std::string>() ); description.setNotNullConstraint( sequenceNameColumn() ); description.insertColumn( sequenceValueColumn(),coral::AttributeSpecification::typeNameForType<int>() ); description.setNotNullConstraint( sequenceValueColumn() ); description.setPrimaryKey( std::vector< std::string >( 1, sequenceNameColumn() ) ); schema().createTable( description ); }
void ora::OraSequenceTable::drop | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 228 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, and python::IdGenerator::schema.
void ora::OraSequenceTable::erase | ( | const std::string & | sequenceName | ) | [virtual] |
Implements ora::ISequenceTable.
Definition at line 193 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, and python::IdGenerator::schema.
{ coral::AttributeList whereData; whereData.extend<std::string>(sequenceNameColumn()); whereData[ sequenceNameColumn() ].data<std::string>() = sequenceName; std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() ); schema().tableHandle( name() ).dataEditor().deleteRows( whereClause, whereData ); }
bool ora::OraSequenceTable::exists | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 205 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, and python::IdGenerator::schema.
bool ora::OraSequenceTable::getLastId | ( | const std::string & | sequenceName, |
int & | lastId | ||
) | [virtual] |
Implements ora::ISequenceTable.
Definition at line 158 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, o2o::query, and python::IdGenerator::schema.
{ std::auto_ptr< coral::IQuery > query( schema().tableHandle( name() ).newQuery() ); query->limitReturnedRows( 1, 0 ); query->addToOutputList( sequenceValueColumn() ); query->defineOutputType( sequenceValueColumn(), coral::AttributeSpecification::typeNameForType<int>() ); query->setForUpdate(); std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() ); coral::AttributeList rowData; rowData.extend<std::string>(sequenceNameColumn()); rowData.begin()->data< std::string >() = sequenceName; query->setCondition( whereClause, rowData ); coral::ICursor& cursor = query->execute(); if ( cursor.next() ) { lastId = cursor.currentRow().begin()->data<int >(); return true; } return false; }
std::string ora::OraSequenceTable::name | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 201 of file OraDatabaseSchema.cc.
{ return m_tableName; }
std::string ora::OraSequenceTable::sequenceNameColumn | ( | ) | [static] |
Definition at line 119 of file OraDatabaseSchema.cc.
{ static std::string s_column("NAME"); return s_column; }
std::string ora::OraSequenceTable::sequenceValueColumn | ( | ) | [static] |
Definition at line 124 of file OraDatabaseSchema.cc.
{ static std::string s_column("VALUE"); return s_column; }
void ora::OraSequenceTable::sinchronize | ( | const std::string & | sequenceName, |
int | lastValue | ||
) | [virtual] |
Implements ora::ISequenceTable.
Definition at line 178 of file OraDatabaseSchema.cc.
References mergeVDriftHistosByStation::name, and python::IdGenerator::schema.
{ coral::AttributeList updateData; updateData.extend<std::string>(sequenceNameColumn()); updateData.extend<int>(sequenceValueColumn()); std::string setClause( sequenceValueColumn() + " = :" + sequenceValueColumn() ); std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() ); // Increment the oid in the database as well coral::AttributeList::iterator iAttribute = updateData.begin(); iAttribute->data< std::string >() = sequenceName; ++iAttribute; iAttribute->data< int >() = lastValue; schema().tableHandle( name() ).dataEditor().updateRows( setClause,whereClause,updateData ); }
std::string ora::OraSequenceTable::tableName | ( | ) | [static] |
Definition at line 114 of file OraDatabaseSchema.cc.
{ static std::string s_name("ORA_SEQUENCE"); return s_name; }
std::string ora::OraSequenceTable::m_tableName [private] |
Definition at line 49 of file OraDatabaseSchema.h.