...
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
#include <stdexcept>
|
||||
#include <QString>
|
||||
#include "ImportToOracle.h"
|
||||
#include "../../../db/ocilib/db_oper.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ocilib;
|
||||
|
||||
void l_error_handler(OCI_Error* pError)
|
||||
void l_error_handler( OCI_Error * pError )
|
||||
{
|
||||
string errorString = OCI_ErrorGetString(pError);
|
||||
string errorString = OCI_ErrorGetString( pError );
|
||||
|
||||
std::runtime_error error(OCI_ErrorGetString(pError));
|
||||
std::runtime_error error( OCI_ErrorGetString( pError ) );
|
||||
|
||||
throw error;
|
||||
}
|
||||
@@ -116,8 +117,9 @@ void ImportCarDealerAchievementToOracle( std::string use
|
||||
{
|
||||
OCI_Connection * pConnection = nullptr;
|
||||
OCI_Statement * pStatement = nullptr;
|
||||
int returnCode = 0;
|
||||
|
||||
ostring sqlImport =
|
||||
const otext * szSqlImport =
|
||||
"BEGIN "
|
||||
" car_dealer.data_import_util_pkg.import_cardealer_achvmnt( :a_the_year, "
|
||||
" :a_the_month, "
|
||||
@@ -129,6 +131,34 @@ void ImportCarDealerAchievementToOracle( std::string use
|
||||
" :a_pingan_amount, "
|
||||
" :a_others_amount ); "
|
||||
"END; ";
|
||||
|
||||
//初始化
|
||||
returnCode = OCI_Initialize( l_error_handler, nullptr, OCI_ENV_DEFAULT );
|
||||
|
||||
if ( static_cast<bool>(returnCode) == false )
|
||||
{
|
||||
string errorMessage( "ocilib初始化错误:" );
|
||||
errorMessage.append( get_last_error_message() );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
pConnection = OCI_ConnectionCreate( tnsName.c_str(),
|
||||
userName.c_str(),
|
||||
password.c_str(),
|
||||
OCI_SESSION_DEFAULT );
|
||||
|
||||
pStatement = OCI_StatementCreate( pConnection );
|
||||
|
||||
OCI_AllowRebinding( pStatement, true );
|
||||
OCI_Prepare( pStatement, szSqlImport );
|
||||
|
||||
for ( auto iterAchievement = achievementVector.begin();
|
||||
iterAchievement != achievementVector.end();
|
||||
++iterAchievement )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +167,7 @@ void ImportRepairOrderToOracle( std::string userName,
|
||||
std::string tnsName,
|
||||
std::vector<RepairOrder> & orderVector )
|
||||
{
|
||||
ostring sqlImport =
|
||||
const otext * szSqlImport =
|
||||
"BEGIN"
|
||||
" car_dealer.dat:a_import_util_pkg.import_repairing_order(:a_branch_name,"
|
||||
" :a_order_no,"
|
||||
@@ -168,50 +198,4 @@ void ImportRepairOrderToOracle( std::string userName,
|
||||
"END;";
|
||||
|
||||
//初始化
|
||||
try
|
||||
{
|
||||
Environment::Initialize();
|
||||
}
|
||||
catch ( exception & error )
|
||||
{
|
||||
string errorMessage = "ocilib初始化失败!";
|
||||
errorMessage.append( error.what() );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
Connection * pConn = nullptr;
|
||||
Statement * pStmt = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
pConn = new Connection( userName, password, tnsName );
|
||||
}
|
||||
catch ( exception & error )
|
||||
{
|
||||
string errorMessage = "连接oracle失败!";
|
||||
errorMessage.append( error.what() );
|
||||
|
||||
Environment::Cleanup();
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
pStmt = new Statement( *pConn );
|
||||
|
||||
pStmt->AllowRebinding( true );
|
||||
}
|
||||
catch ( exception & error )
|
||||
{
|
||||
string errorMessage = "语句执行失败!";
|
||||
errorMessage.append( error.what() );
|
||||
|
||||
Environment::Cleanup();
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
Environment::Cleanup();
|
||||
}
|
||||
|
Reference in New Issue
Block a user