コード例 #1
0
ファイル: odbcapi25w.c プロジェクト: CHINA-JD/prestogres-odbc
RETCODE  SQL_API
SQLErrorW(HENV EnvironmentHandle,
		  HDBC ConnectionHandle, HSTMT StatementHandle,
		  SQLWCHAR *Sqlstate, SQLINTEGER *NativeError,
		  SQLWCHAR *MessageText, SQLSMALLINT BufferLength,
		  SQLSMALLINT *TextLength)
{
	RETCODE	ret;
	SWORD	tlen, buflen;
	char	*qst = NULL, *mtxt = NULL;

	mylog("[SQLErrorW]");
	if (Sqlstate)
		qst = malloc(8);
	buflen = 0;
	if (MessageText && BufferLength > 0)
	{
		buflen = BufferLength * 3 + 1;
		mtxt = malloc(buflen);
	}
	ret = PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
					  qst, NativeError, mtxt, buflen, &tlen);
	if (qst)
		utf8_to_ucs2(qst, strlen(qst), Sqlstate, 5);
	if (NULL != mtxt)
	{
		SQLULEN	tulen = utf8_to_ucs2(mtxt, tlen, MessageText, BufferLength);
		if (NULL != TextLength)
			*TextLength = tulen;
		free(mtxt);
	}
	if (qst)
		free(qst);
	return ret;
}
コード例 #2
0
RETCODE		SQL_API
SQLError(HENV EnvironmentHandle,
		 HDBC ConnectionHandle, HSTMT StatementHandle,
		 SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
		 SQLCHAR *MessageText, SQLSMALLINT BufferLength,
		 SQLSMALLINT *TextLength)
{
	RETCODE	ret;

	mylog("[SQLError]");
	if (NULL != EnvironmentHandle)
		ENTER_ENV_CS((EnvironmentClass *) EnvironmentHandle);
	ret = PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
		   Sqlstate, NativeError, MessageText, BufferLength,
		TextLength);
	if (NULL != EnvironmentHandle)
		LEAVE_ENV_CS((EnvironmentClass *) EnvironmentHandle);
	return ret;
}
コード例 #3
0
ファイル: multibyte.c プロジェクト: greenplum-db/gpclients
static char *
CC_lookup_cs_old(ConnectionClass *self)
{
	char		*encstr = NULL;
	HSTMT		hstmt;
	RETCODE		result;

	result = PGAPI_AllocStmt(self, &hstmt);
	if (!SQL_SUCCEEDED(result))
		return encstr;

	result = PGAPI_ExecDirect(hstmt, "Show Client_Encoding", SQL_NTS, 0);
	if (result == SQL_SUCCESS_WITH_INFO)
	{
		char sqlState[8], errormsg[128], enc[32];

		if (PGAPI_Error(NULL, NULL, hstmt, sqlState, NULL, errormsg,
			sizeof(errormsg), NULL) == SQL_SUCCESS &&
		    sscanf(errormsg, "%*s %*s %*s %*s %*s %s", enc) > 0)
			encstr = strdup(enc);
	}
	PGAPI_FreeStmt(hstmt, SQL_DROP);
	return encstr;
}