Example #1
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!");
	}

}
Example #2
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;
}