conn_from->Connect(
"anyone",
"allowed",
"TAPER",
"DBAPI_Sample");
89conn_to->Connect(
"anyone",
"allowed",
"MS_DEV1",
"DBAPI_Sample");
91unique_ptr<IStatement> stmt_from(conn_from->GetStatement());
92unique_ptr<IStatement> stmt_to(conn_to->GetStatement());
96 sql=
" CREATE TABLE #source_table( \n" 97 "attribute_id INT, \n" 98 "attribute_name VARCHAR(128), \n" 99 "attribute_value VARCHAR(255) \n" 101stmt_from->ExecuteUpdate(
sql);
106 sql=
" CREATE TABLE #destination_table( \n" 107 "attribute_id INT, \n" 108 "attribute_name VARCHAR(128), \n" 109 "attribute_value VARCHAR(255) \n" 111stmt_to->ExecuteUpdate(
sql);
118conn_tmp->Connect(
"anyone",
"allowed",
"TAPER");
121 sql=
"INSERT INTO #source_table VALUES(@attr_id, @attr_name, @attr_value)";
124unique_ptr<ICallableStatement> auto_stmt(conn_tmp->GetCallableStatement(
"sp_server_info"));
125auto_stmt->Execute();
128stmt_from->ExecuteUpdate(
"BEGIN TRANSACTION");
129 while(auto_stmt->HasMoreResults()) {
130unique_ptr<IResultSet> rs(auto_stmt->GetResultSet());
134stmt_from->SetParam(rs->GetVariant(1),
"@attr_id");
135stmt_from->SetParam(rs->GetVariant(2),
"@attr_name");
136stmt_from->SetParam(rs->GetVariant(3),
"@attr_value");
138stmt_from->ExecuteUpdate(
sql);
139stmt_from->ClearParamList();
143stmt_from->ExecuteUpdate(
"COMMIT TRANSACTION");
149 sql=
"INSERT INTO #destination_table VALUES(@attr_id, @attr_name, @attr_value)";
152stmt_from->SendSql(
"SELECT * FROM #source_table");
155stmt_to->ExecuteUpdate(
"BEGIN TRANSACTION");
156 while(stmt_from->HasMoreResults()) {
157unique_ptr<IResultSet> rs(stmt_from->GetResultSet());
161stmt_to->SetParam(rs->GetVariant(1),
"@attr_id");
162stmt_to->SetParam(rs->GetVariant(2),
"@attr_name");
163stmt_to->SetParam(rs->GetVariant(3),
"@attr_value");
165stmt_to->ExecuteUpdate(
sql);
166stmt_to->ClearParamList();
170stmt_to->ExecuteUpdate(
"COMMIT TRANSACTION");
175stmt_to->SendSql(
"SELECT * FROM #destination_table");
176 while(stmt_to->HasMoreResults()) {
177unique_ptr<IResultSet> rs(stmt_to->GetResultSet());
182rs->GetVariant(1).GetInt4() <<
'\t'<<
183rs->GetVariant(2).GetString() <<
'\t'<<
184rs->GetVariant(3).GetString() <<
191cerr << ex.
GetMsg() << endl;
194cerr <<
"Unknown error"<< endl;
CErrHandler - custom error handler.
virtual bool HandleIt(CDB_Exception *ex)
Handle the exceptions resulting from a native API call, one-by-one.
@ eTakeOwnership
An object can take ownership of another.
virtual I_DriverContext * GetDriverContext()=0
Returns the pointer to the general driver interface.
virtual IConnection * CreateConnection(EOwnership ownership=eNoOwnership)=0
@ eBulkInsert
Bulk insert mode.
IDataSource * CreateDs(const string &driver_name, const map< string, string > *attr=0, const string &tag=kEmptyStr)
static CDriverManager & GetInstance()
int GetDBErrCode(void) const
virtual void PushDefConnMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)=0
Add `per-connection' err.message handler "h" to the stack of default handlers which are inherited by ...
virtual void PushCntxMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)=0
Add message handler "h" to process 'context-wide' (not bound to any particular connection) error mess...
const string & GetMsg(void) const
Get message string.
int DemoDbCopyTable(void)
DemoDbCopy - copy one table to another.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4