...
This commit is contained in:
		@@ -1,14 +1,90 @@
 | 
			
		||||
#include <ocilib.h>
 | 
			
		||||
#include <ocilib.hpp>
 | 
			
		||||
#include <stdexcept>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include "ImportToOracle.h"
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
using namespace ocilib;
 | 
			
		||||
 | 
			
		||||
void ImportCarDealerAchievementToOracle( std::string                         userName,
 | 
			
		||||
                                         std::string                         password,
 | 
			
		||||
                                         std::string                         tnsName,
 | 
			
		||||
                                         std::vector<CarDealerAchievement> & achievementVector )
 | 
			
		||||
{
 | 
			
		||||
	
 | 
			
		||||
	ostring sqlImport =
 | 
			
		||||
			"BEGIN "
 | 
			
		||||
			"  car_dealer.data_import_util_pkg.import_cardealer_achvmnt( :a_the_year, "
 | 
			
		||||
			"                                                            :a_the_month, "
 | 
			
		||||
			"                                                            :a_car_dealer_code, "
 | 
			
		||||
			"                                                            :a_checked_achievement, "
 | 
			
		||||
			"                                                            :a_policy_amount, "
 | 
			
		||||
			"                                                            :a_cpic_amount, "
 | 
			
		||||
			"                                                            :a_picc_amount , "
 | 
			
		||||
			"                                                            :a_pingan_amount, "
 | 
			
		||||
			"                                                            :a_others_amount ); "
 | 
			
		||||
			"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->Prepare( sqlImport );
 | 
			
		||||
		pStmt->AllowRebinding( true );
 | 
			
		||||
 | 
			
		||||
		for ( auto iter = achievementVector.begin();
 | 
			
		||||
		      iter != achievementVector.end();
 | 
			
		||||
		      ++iter )
 | 
			
		||||
		{
 | 
			
		||||
			string checkedAchievement = QString("%1").arg( static_cast<double>(iter->getCheckedAchievement())).toStdString();
 | 
			
		||||
 | 
			
		||||
			pStmt->Bind( ":a_the_year", QString::fromStdWString( iter->getTheYear() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_the_month", QString::fromStdWString( iter->getTheMonth() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_car_dealer_code", QString::fromStdWString( iter->getCarDealerCode() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_checked_achievement", checkedAchievement, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_policy_amount", QString::fromStdWString( iter->getTheYear() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_cpic_amount", QString::fromStdWString( iter->getTheYear() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_picc_amount", QString::fromStdWString( iter->getTheYear() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_pingan_amount", QString::fromStdWString( iter->getTheYear() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_others_amount", QString::fromStdWString( iter->getTheYear() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	catch ( exception & error )
 | 
			
		||||
	{
 | 
			
		||||
		string errorMessage = "语句执行失败!";
 | 
			
		||||
		errorMessage.append( error.what() );
 | 
			
		||||
 | 
			
		||||
		Environment::Cleanup();
 | 
			
		||||
 | 
			
		||||
		throw runtime_error( errorMessage );
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user