extern "C" void odbc_SQLSvc_EndTransaction_ccf_ (
    CEE_tag_def cmptag_
  , const struct odbc_SQLSvc_EndTransaction_exc_ *exception_
  , const ERROR_DESC_LIST_def *sqlWarning
  )
{

	SRVR_CALL_CONTEXT	*srvrCallContext = (SRVR_CALL_CONTEXT *)cmptag_;
	CConnect			*pConnection = (CConnect *)srvrCallContext->sqlHandle;

	pConnection->setExceptionErrors(exception_->exception_nr, exception_->exception_detail);
	switch (exception_->exception_nr)
	{
		case CEE_SUCCESS:
			if (sqlWarning->_length > 0)
				pConnection->setDiagRec(sqlWarning);
			break;
		case odbc_SQLSvc_EndTransaction_SQLError_exn_:
			pConnection->setDiagRec(&exception_->u.SQLError);
			break;
		case odbc_SQLSvc_EndTransaction_ParamError_exn_:
			pConnection->setDiagRec(SERVER_ERROR, IDS_PROGRAM_ERROR, exception_->exception_nr, 
					exception_->u.ParamError.ParamDesc, NULL, 
					SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1, pConnection->getSrvrIdentity());
			break;
		case odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:
			break;
		case odbc_SQLSvc_EndTransaction_InvalidConnection_exn_:
			pConnection->setDiagRec(SERVER_ERROR, IDS_08_S01);
			break;
		case odbc_SQLSvc_EndTransaction_TransactionError_exn_:
			char tmpNumBuffer[16];
			_itoa (exception_->exception_detail, tmpNumBuffer, 10);
			pConnection->setDiagRec(SERVER_ERROR, IDS_TRANSACTION_ERROR, exception_->exception_nr,
						tmpNumBuffer, NULL, SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1, pConnection->getSrvrIdentity());
			break;
		default:
			pConnection->sendCDInfo(exception_->exception_nr);
			pConnection->setDiagRec(exception_->exception_nr, ENDTRANSACT_PROCNAME,
					pConnection->getSrvrIdentity());
			break;
	}

} // odbc_SQLSvc_EndTransaction_ccf_()
// Call Completion function for operation 'odbc_SQLSvc_SetConnectionOption'
extern "C" void odbc_SQLSvc_SetConnectionOption_ccf_ (
	CEE_tag_def cmptag_
  , const struct odbc_SQLSvc_SetConnectionOption_exc_ *exception_
  , const ERROR_DESC_LIST_def *sqlWarning
  )
{
	
	SRVR_CALL_CONTEXT	*srvrCallContext = (SRVR_CALL_CONTEXT *)cmptag_;
	CConnect			*pConnection = (CConnect *)srvrCallContext->sqlHandle;

	pConnection->setExceptionErrors(exception_->exception_nr, exception_->exception_detail);
	switch (exception_->exception_nr)
	{
	case CEE_SUCCESS:
		if (sqlWarning->_length > 0)
			pConnection->setDiagRec(sqlWarning);
		break;
	case odbc_SQLSvc_SetConnectionOption_SQLError_exn_:
		pConnection->setDiagRec(&exception_->u.SQLError);
		break;
	case odbc_SQLSvc_SetConnectionOption_ParamError_exn_:
		pConnection->setDiagRec(SERVER_ERROR, IDS_PROGRAM_ERROR, exception_->exception_nr, 
				exception_->u.ParamError.ParamDesc, NULL, 
				SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1, pConnection->getSrvrIdentity());
		break;
	case odbc_SQLSvc_SetConnectionOption_SQLInvalidHandle_exn_: //This error code is used tempororily
		pConnection->setDiagRec(SERVER_ERROR, IDS_HY_000, 0, " SQL_ATTR_AUTOCOMMIT can not be changed when transaction is in progress");
		break;
	case odbc_SQLSvc_SetConnectionOption_InvalidConnection_exn_:
		pConnection->setDiagRec(SERVER_ERROR, IDS_08_S01);
		break;
	default:
		pConnection->sendCDInfo(exception_->exception_nr);
		pConnection->setDiagRec(exception_->exception_nr, SETCONNECT_PROCNAME,
					pConnection->getSrvrIdentity());
		break;
	}
}
SQLRETURN TERMINATE_DIALOG(SRVR_CALL_CONTEXT *srvrCallContext)
{
	CEE_status	sts;
	long timerTimeout;

	odbc_SQLSvc_TerminateDialogue_exc_ exception_;

	CConnect *pConnection = (CConnect *)srvrCallContext->sqlHandle;
	timerTimeout = srvrCallContext->connectionTimeout > 10 ? srvrCallContext->connectionTimeout : 10;
	
	sts = odbc_SQLSvc_TerminateDialogue_(NULL,
		srvrCallContext,
		srvrCallContext->dialogueId,
		&exception_);

	if (sts != CEE_SUCCESS)
	{
		if (sts == CEE_INTERNALFAIL)
		{
			pConnection->setDiagRec(DRIVER_ERROR, IDS_EXCEPTION_MSG,0,"SQL SERVER",
				NULL,SQL_ROW_NUMBER_UNKNOWN,SQL_COLUMN_NUMBER_UNKNOWN,2,"Internal Error","TERMINATE_DIALOG");
			return SQL_ERROR;
		}
		pConnection->setDiagRec(DRIVER_ERROR, IDS_S1_000, sts, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem),
			NULL, SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1, "TERMINATE_DIALOG failed");
		return SQL_SUCCESS_WITH_INFO;
	}

	// Start CCF
	pConnection->setExceptionErrors(exception_.exception_nr, exception_.exception_detail);
	switch (exception_.exception_nr) {
	case CEE_SUCCESS:
		pConnection->resetGetObjRefHdlOutput();
		break;
	case odbc_SQLSvc_TerminateDialogue_SQLError_exn_:
		if (exception_.exception_detail == 25000)
			pConnection->setDiagRec(DRIVER_ERROR, IDS_25_000);
		else
			pConnection->setDiagRec(&exception_.u.SQLError);
		break;
	case odbc_SQLSvc_TerminateDialogue_ParamError_exn_:
		pConnection->setDiagRec(SERVER_ERROR, IDS_PROGRAM_ERROR, exception_.exception_nr, 
							exception_.u.ParamError.ParamDesc);
		break;
	case odbc_SQLSvc_TerminateDialogue_InvalidConnection_exn_:
		pConnection->sendCDInfo(exception_.exception_nr);
		pConnection->setDiagRec(SERVER_ERROR, IDS_08_S01);
		break;
	default:
		pConnection->sendCDInfo(exception_.exception_nr);
		pConnection->setDiagRec(exception_.exception_nr, TERMINATE_DIALOG_PROCNAME,
				pConnection->getSrvrIdentity());
		break;
	}
	if (exception_.exception_detail != 25000)
		CloseIO (pConnection->m_srvrTCPIPSystem);
	// Close CCF

	//
	// cleanup
	//
	if(exception_.exception_nr == odbc_SQLSvc_TerminateDialogue_SQLError_exn_ &&
	   exception_.u.SQLError.errorList._length > 0 )
  	      delete[] exception_.u.SQLError.errorList._buffer;



	switch (pConnection->getExceptionNr())
	{
		case CEE_SUCCESS:
			return SQL_SUCCESS;
		default:
	// if transaction is open return SQL_ERROR
			if (pConnection->getExceptionDetail() == 25000)
				return -25000;
			else
	// Any other errors treat them as if it has been disconnected
				return SQL_SUCCESS_WITH_INFO;
	}

} // TERMINATE_DIALOG()