language-extensions/python/src/PythonExtension.cpp
//-------------------------------------------------------------------------------------------------
// Name: InitSession
//
// Description:
//  Initializes session-specific data. We store the schema and find the main class and
//  method to execute here.
//
// Returns:
//  SQL_SUCCESS on success, else SQL_ERROR
//

InitSession
Description:
Initializes session-specific data. We store the schema and find the main class and
method to execute here.


InitSession Description : Initializes session - specific data . We store the schema and find the main class and method to execute here .
SQLRETURN InitSession(
	SQLGUID      sessionId,
	SQLUSMALLINT taskId,
	SQLUSMALLINT numTasks,
	SQLCHAR      *script,
	SQLULEN      scriptLength,
	SQLUSMALLINT inputSchemaColumnsNumber,
	SQLUSMALLINT parametersNumber,
	SQLCHAR      *inputDataName,
	SQLUSMALLINT inputDataNameLength,
	SQLCHAR      *outputDataName,
	SQLUSMALLINT outputDataNameLength
)
{
	LOG("InitSession");
	SQLRETURN result = SQL_SUCCESS;
	string session = PythonExtensionUtils::ConvertGuidToString(&sessionId);
	try
	{
		g_pySessionMap[session] = new PythonSession();
		g_pySessionMap[session]->Init(
			&sessionId,
			taskId,
			numTasks,
			script,
			scriptLength,
			inputSchemaColumnsNumber,
			parametersNumber,
			inputDataName,
			inputDataNameLength,
			outputDataName,
			outputDataNameLength);
	}
	catch (const exception &ex)
	{
		result = SQL_ERROR;
		LOG_ERROR(ex.what());
	}
	catch (const bp::error_already_set&)
	{
		result = SQL_ERROR;
		LOG_ERROR("Python error: " + PythonExtensionUtils::ParsePythonException());
	}
	catch (...)
	{
		result = SQL_ERROR;
		LOG_ERROR("Unexpected exception occurred in function InitSession()");
	}
	return result;
}
SQLRETURN InitSession ( SQLGUID sessionId , SQLUSMALLINT taskId , SQLUSMALLINT numTasks , SQLCHAR * script , SQLULEN scriptLength , SQLUSMALLINT inputSchemaColumnsNumber , SQLUSMALLINT parametersNumber , SQLCHAR * inputDataName , SQLUSMALLINT inputDataNameLength , SQLCHAR * outputDataName , SQLUSMALLINT outputDataNameLength ) { LOG ( " " ) ; SQLRETURN result = SQL_SUCCESS ; string session = PythonExtensionUtils :: ConvertGuidToString ( & sessionId ) ; try { g_pySessionMap [ session ] = new PythonSession ( ) ; g_pySessionMap [ session ] -> Init ( & sessionId , taskId , numTasks , script , scriptLength , inputSchemaColumnsNumber , parametersNumber , inputDataName , inputDataNameLength , outputDataName , outputDataNameLength ) ; } catch ( const exception & ex ) { result = SQL_ERROR ; LOG_ERROR ( ex . what ( ) ) ; } catch ( const bp :: error_already_set & ) { result = SQL_ERROR ; LOG_ERROR ( " " + PythonExtensionUtils :: ParsePythonException ( ) ) ; } catch ( ... ) { result = SQL_ERROR ; LOG_ERROR ( " " ) ; } return result ; }
Name: InitSession
Description:
Initializes session-specific data.
Name : InitSession Description : Initializes session - specific data .