改c
This commit is contained in:
		@@ -6,6 +6,16 @@
 | 
			
		||||
using namespace std;
 | 
			
		||||
using namespace ocilib;
 | 
			
		||||
 | 
			
		||||
void l_error_handler(OCI_Error* pError)
 | 
			
		||||
{
 | 
			
		||||
	string errorString = OCI_ErrorGetString(pError);
 | 
			
		||||
 | 
			
		||||
	std::runtime_error error(OCI_ErrorGetString(pError));
 | 
			
		||||
 | 
			
		||||
	throw error;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
void ImportCarDealerAchievementToOracle( std::string                         userName,
 | 
			
		||||
                                         std::string                         password,
 | 
			
		||||
                                         std::string                         tnsName,
 | 
			
		||||
@@ -72,15 +82,15 @@ void ImportCarDealerAchievementToOracle( std::string                         use
 | 
			
		||||
			string pinganAmount       = QString( "%1" ).arg( iter->getPinganAmount() ).toStdString();
 | 
			
		||||
			string othersAmount       = QString( "%1" ).arg( iter->getOthersAmount() ).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", policyAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_cpic_amount", cpicAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_picc_amount", piccAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_pingan_amount", pinganAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_others_amount", othersAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>( ostring(":a_the_year"), ostring(QString::fromStdWString( iter->getTheYear() ).toStdString().c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_the_month"), ostring(QString::fromStdWString( iter->getTheMonth() ).toStdString().c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_car_dealer_code"), ostring(QString::fromStdWString( iter->getCarDealerCode() ).toStdString().c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_checked_achievement"), ostring(checkedAchievement.c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_policy_amount"), ostring(policyAmount.c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_cpic_amount"), ostring(cpicAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_picc_amount"), ostring(piccAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_pingan_amount"), ostring(pinganAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_others_amount"), ostring(othersAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
 | 
			
		||||
			pStmt->ExecutePrepared();
 | 
			
		||||
		}
 | 
			
		||||
@@ -97,6 +107,30 @@ void ImportCarDealerAchievementToOracle( std::string                         use
 | 
			
		||||
 | 
			
		||||
	Environment::Cleanup();
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
void ImportCarDealerAchievementToOracle( std::string                         userName,
 | 
			
		||||
                                         std::string                         password,
 | 
			
		||||
                                         std::string                         tnsName,
 | 
			
		||||
                                         std::vector<CarDealerAchievement> & achievementVector )
 | 
			
		||||
{
 | 
			
		||||
	OCI_Connection * pConnection = nullptr;
 | 
			
		||||
	OCI_Statement *  pStatement  = nullptr;
 | 
			
		||||
 | 
			
		||||
	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; ";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void ImportRepairOrderToOracle( std::string                userName,
 | 
			
		||||
                                std::string                password,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										67
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
			
		||||
 | 
			
		||||
#include <exception>
 | 
			
		||||
#include <stdexcept>
 | 
			
		||||
#include "db_oper.h"
 | 
			
		||||
 | 
			
		||||
const int ERROR_MESSAGE_LENGTH = 1001;
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
void get_error_message(OCI_Error * pError, char * pszMessage, size_t length);
 | 
			
		||||
 | 
			
		||||
void initOciLib()
 | 
			
		||||
{
 | 
			
		||||
	int    returnCode = 0;
 | 
			
		||||
	char * pszErrorMessage = (char *)malloc(sizeof(char) * ERROR_MESSAGE_LENGTH);
 | 
			
		||||
 | 
			
		||||
	returnCode = OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
 | 
			
		||||
 | 
			
		||||
	if (!returnCode )
 | 
			
		||||
	{
 | 
			
		||||
		get_error_message(OCI_GetLastError(), pszErrorMessage, ERROR_MESSAGE_LENGTH - 1);
 | 
			
		||||
 | 
			
		||||
		string message("OCILIB初始化失败!\n");
 | 
			
		||||
 | 
			
		||||
		message += pszErrorMessage;
 | 
			
		||||
 | 
			
		||||
		throw runtime_error(message);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	free(pszErrorMessage);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void releaseOciLib()
 | 
			
		||||
{
 | 
			
		||||
	OCI_Cleanup();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void get_error_message(OCI_Error * pError, char * pszMessage, size_t length)
 | 
			
		||||
{
 | 
			
		||||
	//防御性验证
 | 
			
		||||
	if (pError == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		pszMessage[0] = NULL;
 | 
			
		||||
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const otext * psz = OCI_ErrorGetString(pError);
 | 
			
		||||
 | 
			
		||||
	strcpy_s(pszMessage, length, psz);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void error_handler(OCI_Error * pError)
 | 
			
		||||
{
 | 
			
		||||
	std::runtime_error error(OCI_ErrorGetString(pError));
 | 
			
		||||
 | 
			
		||||
	OCI_Cleanup();
 | 
			
		||||
 | 
			
		||||
	throw error;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string get_last_error_message()
 | 
			
		||||
{
 | 
			
		||||
	OCI_Error * pError = OCI_GetLastError();
 | 
			
		||||
 | 
			
		||||
	return std::string(OCI_ErrorGetString(pError));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
 | 
			
		||||
#ifndef _DB_OPER_H
 | 
			
		||||
#define _DB_OPER_H
 | 
			
		||||
 | 
			
		||||
#include <ocilib.h>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <unordered_map>
 | 
			
		||||
 | 
			
		||||
void initOciLib();
 | 
			
		||||
 | 
			
		||||
void releaseOciLib();
 | 
			
		||||
 | 
			
		||||
void error_handler(OCI_Error * pError);
 | 
			
		||||
 | 
			
		||||
std::string get_last_error_message();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Reference in New Issue
	
	Block a user