本文整理汇总了C++中Database::ExecuteNonQueryCached方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::ExecuteNonQueryCached方法的具体用法?C++ Database::ExecuteNonQueryCached怎么用?C++ Database::ExecuteNonQueryCached使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::ExecuteNonQueryCached方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertEvent
void EventsWatcherDbOp::InsertEvent( const string& dadbuffer, const string& message )
{
Database* data = getData();
ParametersVector params;
DataParameterBase *dadParam = m_DatabaseProvider->createParameter( DataType::LARGE_CHAR_TYPE );
dadParam->setDimension( dadbuffer.length() );
dadParam->setString( dadbuffer );
dadParam->setName( "DAD_buffer" );
params.push_back( dadParam );
DataParameterBase *messageParam = m_DatabaseProvider->createParameter( DataType::LARGE_CHAR_TYPE );
messageParam->setDimension( message.length() );
messageParam->setName( "XML_buffer" );
messageParam->setString( message );
params.push_back( messageParam );
DataParameterBase *paramReturnCode = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE, DataParameterBase::PARAM_OUT );
DataParameterBase *paramReturnMessage = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE, DataParameterBase::PARAM_OUT );
// return code from upload proc
paramReturnCode->setDimension( 11 );
params.push_back( paramReturnCode );
// return message from upload proc
paramReturnMessage->setDimension( 1024 );
params.push_back( paramReturnMessage );
data->BeginTransaction();
try
{
data->ExecuteNonQueryCached( DataCommand::SP, "INSERTEVENTSBATCH", params );
string returnCode = StringUtil::Trim( paramReturnCode->getString() );
DEBUG( "Insert XML data return code : [" << returnCode << "]" );
if ( returnCode != "0" )
{
stringstream messageBuffer;
messageBuffer << "Error inserting XML. Message : [" << paramReturnMessage->getString() << "]";
TRACE( messageBuffer.str() );
TRACE( "Original_buffer [" << message << "]" );
throw runtime_error( messageBuffer.str() );
}
}
catch( const std::exception& ex )
{
TRACE( "Insert event failed [" << ex.what() << "]" );
}
catch( ... )
{
TRACE( "Insert event failed [unknown reason]" );
}
data->EndTransaction( TransactionType::COMMIT );
DEBUG2( "done" );
}