9 #include "CoralBase/AttributeList.h"
10 #include "CoralBase/Attribute.h"
11 #include "RelationalAccess/ISessionProxy.h"
12 #include "RelationalAccess/ITransaction.h"
13 #include "RelationalAccess/ITable.h"
14 #include "RelationalAccess/TableDescription.h"
15 #include "RelationalAccess/ITableDataEditor.h"
16 #include "RelationalAccess/ISchema.h"
17 #include "RelationalAccess/IQuery.h"
18 #include "RelationalAccess/ICursor.h"
19 #include "RelationalAccess/SchemaException.h"
27 const std::string& seqname,
28 coral::ISessionProxy*
proxy,
30 m_dbname(
dbname), m_seqname(seqname), m_proxy(
proxy), m_table(0) {
33 const std::string keytblname=
m_dbname+
"_CORACOOLKEYS";
38 catch (coral::SchemaException&
e) {
41 coral::TableDescription tdesc(keytblname);
42 tdesc.setName(keytblname);
43 tdesc.insertColumn(
"SEQNAME",
"string",63,
false);
44 tdesc.insertColumn(
"SEQVAL",
"int");
45 tdesc.setPrimaryKey(
"SEQNAME");
48 m_proxy->transaction().commit();
50 m_proxy->transaction().start(
false);
56 "CoraCoolSequence::CoraCoolSequence");
64 data.extend<std::string>(
"SEQNAME");
65 data.extend<
int>(
"SEQVAL");
67 data[1].data<
int>()=0;
68 coral::ITableDataEditor& editor=
m_table->dataEditor();
69 editor.insertRow(
data);
79 bindvar.extend<std::string>(
"SKEY");
81 bindvar.extend<
int>(
"SINC");
82 bindvar[1].data<
int>()=inc;
83 coral::ITableDataEditor& editor=
m_table->dataEditor();
84 int rowsupdated=editor.updateRows(
"SEQVAL=SEQVAL+:SINC",
85 "SEQNAME=:SKEY",bindvar);
87 "Unexpected number of rows locked in keytable",
88 "CoraCoolSequence::CoraCoolSequence");
91 "CoraCoolSequence::fetch");
98 const std::string keytblname=
m_dbname+
"_CORACOOLKEYS";
103 bindvar.extend<std::string>(
"SKEY");
104 bindvar[0].data<std::string>()=
m_seqname;
105 query->setCondition(
"SEQNAME=:SKEY",bindvar);
106 query->setRowCacheSize(2);
107 query->defineOutputType(
"SEQVAL",
"int");
115 keyval=
res[
"SEQVAL"].data<
int>();
126 bindvar.extend<std::string>(
"SKEY");
127 bindvar[0].data<std::string>()=
m_seqname;
128 coral::ITableDataEditor& editor=
m_table->dataEditor();
129 long rows=editor.deleteRows(
"SEQNAME=:SKEY",bindvar);