예제 #1
0
SQLVarParms SQLVarParms::operator +(const SQLVarParms& other) const
{
	if (other.size() <= size()) 
	{
		return *this;
	}

	SQLVarParms New = *this;

	for (size_t nIndex = size(); nIndex < other.size(); nIndex++) 
	{
		New.push_back(other[nIndex]);
	}

	return New;
}
예제 #2
0
void SQLCode::_BuildSQLStatement(SQLVarParms& varParms, SQLStatement& rSqlStatement)
{
	BOOST_LOG_FUNCTION();
	std::string strSQLKey;
	SQLStatement SQLFormats;
	int nDbType = 0;
	size_t uiTotalSQLSize = 0;	

	try
	{
		size_t uVarCount = varParms.size();
		if (uVarCount < 1)
		{
			throw DataAccessException(ER_DB_ERR_SQLCode, "the PrepareStatement parameter count error!");
		}

		_GetDbTypeAndSQLKey(varParms, strSQLKey);//strSQLID=strSQLKey=varParms[0]
		_GetSQLFormat(strSQLKey, SQLFormats);

		_BuildNormalSQL(varParms, SQLFormats, rSqlStatement);
		rSqlStatement.logInfo();
	}
	catch (DataAccessException& e)
	{
		throw e;
	}
	catch (...)
	{
		throw DataAccessException(ER_DB_ERR_UNKNOWN, "buildSQLStatement error!");
	}

}
예제 #3
0
size_t  SQLCode::_GetSQLSize(const SQLVarParms& varParms, const std::string& strFormat, int nSQLType)
{
	BOOST_LOG_FUNCTION();

	size_t uiTotalSize = strFormat.size();
	size_t uVarCount   = varParms.size();
	size_t nIndex = 1;	
	for (; nIndex < uVarCount; nIndex++)
	{
		uiTotalSize += varParms[nIndex].length(nSQLType);
	}

	return uiTotalSize;
}
예제 #4
0
size_t  SQLCode::_GetSQLSize(const SQLVarParms& varParms, const std::string& strFormat, int nSQLType)
{
	size_t uiTotalSize = strFormat.size();
	size_t uVarCount   = varParms.size();
	if ( defMINPARAMSIZE == uVarCount )
		return uiTotalSize;

	size_t i = defMINPARAMSIZE;	
	for (; i < uVarCount; i++)
	{
		uiTotalSize += varParms[i].length(nSQLType);
	}

	return uiTotalSize;
}
예제 #5
0
void  SQLCode::_BuildSQL(const SQLVarParms& varParms, const std::string& strSQLFormat, std::string& strSQL, int nSQLType)
{	
	size_t uVarCount = varParms.size();
	if (defMINPARAMSIZE == uVarCount)	
	{
		strSQL = strSQLFormat;	
	}
	else
	{
		char szSQL[MAX_SQLSTRING_LEN+1] = {0};

		DEF_CONSTRUCT_SQLCODE(MAX_SQLSTRING_LEN, nSQLType);		

		strSQL = szSQL;
	}
}
예제 #6
0
void SQLCode::buildSQLStatement(SQLVarParms& varParms, SQLStatement& rSqlStatement)
{
	FUNCTION_ENTRY("SQLCode::_ConstructSQLStatement()");
	std::string strSQLKey;
	SQLStatement SQLFormats;
	int nDbType = 0;
	size_t uiTotalSQLSize = 0;	

	try
	{
		size_t uVarCount = varParms.size();
		if (uVarCount < defMINPARAMSIZE)
			TA_THROW(BadParamCount("the PrepareStatement parameter count error"));

		_GetDbTypeAndSQLKey(varParms, strSQLKey);
		_GetSQLFormat(strSQLKey, SQLFormats);
		//_GetSQLID(strSQLKey, rSqlStatement);

		_BuildNormalSQL(varParms, SQLFormats, rSqlStatement);
		_PrintSQL(strSQLKey, rSqlStatement);			
	}
	catch (BadParamCount* e)
	{
		SQLCodeException SQLException(e->what());
		throw SQLException;
	}
	catch (BadIndex* e)
	{
		SQLCodeException SQLException(e->what());
		throw SQLException;
	}
	catch(DbTypeNotSupported* e)
	{
		SQLCodeException SQLException(e->what());
		throw SQLException;
	}
	catch (...)
	{
		SQLCodeException SQLException("Unknown SQLCode exception");
		throw SQLException;
	}

	FUNCTION_EXIT;
}
예제 #7
0
void  SQLCode::_BuildSQL(const SQLVarParms& varParms, const std::string& strSQLFormat, std::string& strSQL, int nSQLType)
{	
	BOOST_LOG_FUNCTION();

	size_t uVarCount = varParms.size();

	{
		int nSQLLen = DEF_INT_MAXLINELEN;
		char* szSQL = new char[nSQLLen];

		memset(szSQL, 0, nSQLLen);

		DEF_CONSTRUCT_SQLCODE(DEF_INT_MAXLINELEN, nSQLType);		

		strSQL = szSQL;
		delete[] szSQL;
		szSQL = NULL;
	}
}
예제 #8
0
void  SQLCode::_BuildLargeSQL(const SQLVarParms& varParms, size_t uSQLSize, const std::string& strSQLFormat, std::string& strSQL, int nSQLType)
{
	size_t uVarCount = varParms.size();
	if (defMINPARAMSIZE == uVarCount)	
	{
		strSQL = strSQLFormat;	
	}
	else
	{
		char *szSQL = new char[uSQLSize + 1];		
		memset(szSQL, 0, uSQLSize + 1);

		DEF_CONSTRUCT_SQLCODE(uSQLSize, nSQLType);		

		strSQL = szSQL;

		delete[] szSQL;
		szSQL = 0;
	}
	
}