- remove odbc_sql_set_env_attr()

- fixed odbc_sql_set_env_attr_int()
This commit is contained in:
eknauel 2003-05-13 13:45:32 +00:00
parent 7c40f1b3f4
commit e981de7c4c
1 changed files with 68 additions and 16 deletions

View File

@ -28,20 +28,6 @@ s48_value odbc_alloc_environment_handle()
S48_UNSPECIFIC);
}
/* given a valid environment handle (type SQLHENV) this function
* sets the environment attributes. This needs to be done before
* allocating a connection handle */
s48_value odbc_sql_set_env_attr(SQLHENV env_handle)
{
SQLRETURN retval;
retval = SQLSetEnvAttr(env_handle, SQL_ATTR_ODBC_VERSION,
(void *)SQL_OV_ODBC3, 0);
ODBC_DEBUG_PRINTF_2("odbc_set_environment() %x\n", env_handle);
return s48_enter_integer(retval);
}
/* Given a valid environment handle get a connection handle */
s48_value odbc_alloc_connection_handle(s48_value env_handle)
{
@ -513,9 +499,9 @@ s48_value odbc_sql_set_env_attr_int(s48_value env_handle,
eh = (SQLHENV) s48_extract_integer(env_handle);
attr = (SQLINTEGER) s48_extract_integer(attribute);
val = s48_extract_integer(value);
val = (SQLUINTEGER) s48_extract_integer(value);
ODBC_DEBUG_PRINTF_4("odbc_sql_set_env_attr_int eh %x attr %d value %d\n", eh, attr, val);
retval = SQLSetEnvAttr(eh, attr, (SQLPOINTER) &val, sizeof(SQLUINTEGER));
retval = SQLSetEnvAttr(eh, attr, (SQLPOINTER) val, sizeof(SQLUINTEGER));
return s48_enter_integer(retval);
#else
@ -2187,6 +2173,72 @@ void odbc_sql_alloc(void **buffer, size_t buffer_len, size_t type_len)
RAISE_ODBC_BUFFER_ALLOC_ERROR((buffer_len+1)*type_len);
}
void copy_scheme_value_to_buffer(s48_value schemeval, void **buffer,
SQLSMALLINT ctypeid)
{
ODBC_DEBUG_PRINTF_3("s48_value_to_buffer(): ctypeid %d buffer %x\n",
ctypeid, buffer);
switch (ctypeid)
{
case SQL_C_CHAR:
*buffer = (void *)calloc(S48_STRING_LENGTH(schemeval)+1, sizeof(SQLCHAR));
if (*buffer == NULL)
RAISE_ODBC_BUFFER_ALLOC_ERROR((S48_STRING_LENGTH(schemeval)+1)*sizeof(SQLCHAR));
strcpy(*buffer, s48_extract_string(schemeval));
break;
case SQL_C_SSHORT: case SQL_C_SHORT: case SQL_C_USHORT:
/* SQL_C_SHORT has no default conversion, treat it like SQL_C_SHORT */
*buffer = (void *)malloc(sizeof(SQLSMALLINT));
if (*buffer == NULL)
RAISE_ODBC_BUFFER_ALLOC_ERROR(sizeof(SQLSMALLINT));
if (ctypeid == SQL_C_USHORT)
*((SQLSMALLINT *) *buffer) = (SQLUSMALLINT) s48_extract_unsigned_integer(schemeval);
else
*((SQLSMALLINT *) *buffer) = (SQLSMALLINT) s48_extract_integer(schemeval);
break;
case SQL_C_SLONG: case SQL_C_LONG: case SQL_C_ULONG:
/* SQL_C_LONG has no default conversion, treat it like SQL_C_LONG */
*buffer = (void *)malloc(sizeof(SQLINTEGER));
if (*buffer == NULL)
RAISE_ODBC_BUFFER_ALLOC_ERROR(sizeof(SQLINTEGER));
if (ctypeid == SQL_C_ULONG)
*((SQLUINTEGER *) *buffer) = (SQLUINTEGER) s48_extract_unsigned_integer(schemeval);
else
*((SQLINTEGER *) *buffer) = (SQLINTEGER) s48_extract_integer(schemeval);
break;
case SQL_C_FLOAT:
*buffer = (void *)malloc(sizeof(SQLREAL));
if (*buffer == NULL)
RAISE_ODBC_BUFFER_ALLOC_ERROR(sizeof(SQLREAL));
*((SQLREAL *) *buffer) = (SQLREAL) s48_extract_double(schemeval);
break;
case SQL_C_DOUBLE:
*buffer = (void *)malloc(sizeof(SQLDOUBLE));
if (*buffer == NULL)
RAISE_ODBC_BUFFER_ALLOC_ERROR(sizeof(SQLDOUBLE));
*((SQLDOUBLE *) *buffer) = (SQLDOUBLE) s48_extract_double(schemeval);
break;
/* case SQL_C_TINYINT: case SQL_C_STINYINT: case SQL_C_UTINYINT: */
/* SQL_C_TINYINT has no default conversion, treat it like SQL_C_STINYINT */
/* *buffer = (void *)malloc(sizeof(SQLTINYINT)); */
/* if (*buffer == NULL) */
/* RAISE_ODBC_BUFFER_ALLOC_ERROR(sizeof(SQLTINYINT)); */
/* if (ctypeid == SQL_C_UTINYINT) */
/* *((SQLUTINYINT *) *buffer) = (SQLUTINYINT) s48_extract_unsigned_integer(schemeval); */
/* else */
/* *((SQLSTINYINT *) *buffer) = (SQLSTINYINT) s48_extract_integer(schemeval); */
/* break; */
default:
RAISE_ODBC_UNKNOWN_C_TYPE_IDENTIFIER_ERROR(NULL, ctypeid);
}
}
s48_value buffer_to_s48_value(void *buffer, SQLSMALLINT ctypeid)
{
ODBC_DEBUG_PRINTF_3("buffer_to_s48_value(): %x %d\n", buffer, ctypeid);