- Support for odbc 1.0 alloc functions

This commit is contained in:
eknauel 2002-10-11 08:06:45 +00:00
parent 41d219a5c1
commit d1142b703c
3 changed files with 81 additions and 20 deletions

View File

@ -12,7 +12,6 @@
* call odbc_set_environment to set the ODBC version */
s48_value odbc_alloc_environment_handle()
{
SQLHENV henv;
SQLRETURN retval;
@ -20,23 +19,14 @@ s48_value odbc_alloc_environment_handle()
ODBC_DEBUG_PRINTF_2("odbc_alloc_environment(): %x\n", henv);
switch (retval)
{
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
{
odbc_sql_set_env_attr(henv);
return s48_enter_integer((long)henv);
}
case SQL_ERROR:
{
ODBC_RAISE_EXCEPTION("SQLAllocHandle returned SQL_ERROR");
break;
}
default:
{
ODBC_RAISE_EXCEPTION("SQLAllocHandle unknown return value");
break;
}
}
{
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
return s48_enter_integer(henv);
case SQL_ERROR:
ODBC_RAISE_EXCEPTION("SQLAllocHandle returned SQL_ERROR");
default:
ODBC_RAISE_EXCEPTION("SQLAllocHandle unknown return value");
}
}
/* given a valid environment handle (type SQLHENV) this function
@ -147,6 +137,72 @@ s48_value odbc_alloc_statement_handle(s48_value conn_handle) {
}
}
/* for ODBC 1.0 compatibility */
s48_value odbc_sql_alloc_env()
{
SQLRETURN retval;
SQLHENV eh;
ODBC_DEBUG_PRINTF("odbc_sql_alloc_env()\n");
retval = SQLAllocEnv(&eh);
switch (retval)
{
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
return s48_enter_inteeger(eh);
case SQL_ERROR:
ODBC_RAISE_EXCEPTION("SQLAllocHandle() returned SQL_ERROR");
default:
ODBC_RAISE_EXCEPTION("SQLAllocHandle() returned unknown error code");
}
}
s48_value odbc_sql_alloc_connect(s48_value env_handle)
{
SQLRETURN retval;
SQLHENV eh;
SQLHDBC ch;
eh = (SQLHENV) s48_extract_integer(env_handle);
ODBC_DEBUG_PRINTF("odbc_sql_alloc_connect(): eh:%d\n");
retval = SQLAllocConnect(ch, &eh);
switch (retval)
{
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
return s48_enter_integer(ch);
case SQL_ERROR:
ODBC_RAISE_EXCEPTION("SQLAllocConnect returned SQL_ERROR");
case SQL_INVALID_HANDLE:
ODBC_RAISE_EXCEPTION("SQLAllocConnect got invalid handle");
default:
ODBC_RAISE_EXCEPTION("SQLAllocConnect returned unknown error");
}
}
s48_value odbc_sql_alloc_stmt(s48_value conn_handle)
{
SQLRETURN retval;
SQLHDBC ch;
SQLHSTMT sh;
ch = (SQLHDBC) s48_extract_integer(conn_handle);
ODBC_DEBUG_PRINTF("odbc_sql_alloc_stmt(): ch:%d\n");
retval = SQLAllocStmt(ch, &eh);
switch (retval)
{
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
return s48_enter_integer(eh);
case SQL_ERROR:
ODBC_RAISE_EXCEPTION("SQLAllocStmt returned SQL_ERROR");
case SQL_INVALID_HANDLE:
ODBC_RAISE_EXCEPTION("SQLAllocStmt got invalid handle");
default:
ODBC_RAISE_EXCEPTION("SQLAllocStmt returned unknown error code");
}
}
/* Connect to a server */
s48_value odbc_sql_connect(s48_value connection_handle,
s48_value ds_name,
@ -794,7 +850,6 @@ s48_value odbc_sql_set_env_attr_int(s48_value env_handle,
s48_value attribute,
s48_value value)
{
SQLHENV eh;
SQLINTEGER attr;
SQLUINTEGER val;

View File

@ -178,6 +178,11 @@ s48_value odbc_alloc_connection_handle(s48_value env_handle);
/* Given a valid connection handle get a statement handle */
s48_value odbc_alloc_statement_handle(s48_value stmt_handle);
/* for ODBC 1.0 compatibility */
s48_value odbc_sql_alloc_env();
s48_value odbc_sql_alloc_connect(s48_value env_handle);
s48_value odbc_sql_alloc_stmt(s48_value conn_handle);
/* Connect to a server */
s48_value odbc_sql_connect(s48_value connection_handle,
s48_value ds_name,

View File

@ -439,7 +439,8 @@
;;; PART 1
(define (odbc-alloc-environment-handle)
(let ((env-handle (really-make-environment-handle (odbc-alloc-environment-handle-internal))))
(let ((env-handle (really-make-environment-handle
(odbc-alloc-environment-handle-internal))))
(add-finalizer! env-handle odbc-sql-free-handle)
env-handle))