+ don't assume driver manager implementing API version >= 0x300
- removed functions 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) + For driver managers < 0x300 s48_value odbc_alloc_environment_handle() s48_value odbc_alloc_connection_handle(s48_value env_handle) s48_value odbc_alloc_statement_handle(s48_value stmt_handle) call SQLAllocEnv(), SQLAllocConnect(), SQLAllocStmt() automatically + removed scheme functions odbc10-sql-alloc-env odbc10-sql-alloc-connect odbc10-sql-alloc-stmt
This commit is contained in:
parent
2c1385f136
commit
c9194d9ba7
225
scsh/odbc/odbc.c
225
scsh/odbc/odbc.c
|
@ -14,18 +14,31 @@ s48_value odbc_alloc_environment_handle()
|
|||
{
|
||||
SQLHENV henv;
|
||||
SQLRETURN retval;
|
||||
|
||||
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
retval = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
|
||||
ODBC_DEBUG_PRINTF_2("odbc_alloc_environment(): %x\n", henv);
|
||||
|
||||
ODBC_DEBUG_PRINTF_2("SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, ...): %x\n", henv);
|
||||
#else
|
||||
retval = SQLAllocEnv(&henv);
|
||||
ODBC_DEBUG_PRINTF_2("SQLAllocEnv(...): %x\n", henv);
|
||||
#endif /* (ODBCVER >= 0x300) */
|
||||
|
||||
switch (retval)
|
||||
{
|
||||
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
|
||||
return s48_enter_integer((long)henv);
|
||||
case SQL_ERROR:
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle returned SQL_ERROR");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocEnv returned SQL_ERROR");
|
||||
#endif /* (ODBCVER >= 0x300) */
|
||||
default:
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle unknown return value");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocEnv unknown return value");
|
||||
#endif /* (ODBCVER >= 0x300) */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,8 +87,13 @@ s48_value odbc_alloc_connection_handle(s48_value env_handle) {
|
|||
|
||||
envh = (SQLHENV) s48_extract_integer(env_handle);
|
||||
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
retval = SQLAllocHandle(SQL_HANDLE_DBC, envh, &hdbc);
|
||||
ODBC_DEBUG_PRINTF_3("odbc_alloc_connection_handle() %x %x\n", envh, hdbc);
|
||||
ODBC_DEBUG_PRINTF_3("SQLAllocHandle(SQL_HANDLE_DBC, %x, ...): %x\n", envh, hdbc);
|
||||
#else
|
||||
retval = SQLAllocConnect(envh, &hdbc);
|
||||
ODBC_DEBUG_PRINTF_3("SQLAllocConnect(%x, ...): %x\n", envh, hdbc);
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
|
||||
switch (retval)
|
||||
{
|
||||
|
@ -85,17 +103,29 @@ s48_value odbc_alloc_connection_handle(s48_value env_handle) {
|
|||
}
|
||||
case SQL_ERROR:
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle returned SQL_ERROR");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocConnect returned SQL_ERROR");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
break;
|
||||
}
|
||||
case SQL_INVALID_HANDLE:
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle got invalid handle");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocConnect got invalid handle");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle returned unknown error code");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocConnect returned unknown error code");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -109,9 +139,14 @@ s48_value odbc_alloc_statement_handle(s48_value conn_handle) {
|
|||
SQLHANDLE ch;
|
||||
|
||||
ch = (SQLHANDLE) s48_extract_integer(conn_handle);
|
||||
retval = SQLAllocHandle(SQL_HANDLE_STMT, ch, &hstmt);
|
||||
|
||||
ODBC_DEBUG_PRINTF_3("odbc_alloc_statement_handle() %x %x\n", ch, hstmt);
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
retval = SQLAllocHandle(SQL_HANDLE_STMT, ch, &hstmt);
|
||||
ODBC_DEBUG_PRINTF_3("SQLAllocHandle() %x %x\n", ch, hstmt);
|
||||
#else
|
||||
retval = SQLAllocStmt(ch, &hstmt);
|
||||
ODBC_DEBUG_PRINTF_3("SQLAllocStmt() %x %x\n", ch, hstmt);
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
|
||||
switch (retval)
|
||||
{
|
||||
|
@ -121,90 +156,34 @@ s48_value odbc_alloc_statement_handle(s48_value conn_handle) {
|
|||
}
|
||||
case SQL_ERROR:
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle returned SQL_ERROR");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocStmt returned SQL_ERROR");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
break;
|
||||
}
|
||||
case SQL_INVALID_HANDLE:
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle got invalid handle");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocStmt returned SQL_ERROR");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle returned unknown error code");
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocStmt returned unknown error code");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* for ODBC 1.0 compatibility */
|
||||
s48_value odbc_sql_alloc_env()
|
||||
{
|
||||
SQLRETURN retval;
|
||||
SQLHENV eh;
|
||||
|
||||
ODBC_DEBUG_PRINTF_1("odbc_sql_alloc_env()\n");
|
||||
|
||||
retval = SQLAllocEnv(&eh);
|
||||
switch (retval)
|
||||
{
|
||||
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
|
||||
return s48_enter_integer((long)eh);
|
||||
case SQL_ERROR:
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle() returned SQL_ERROR");
|
||||
default:
|
||||
ODBC_RAISE_EXCEPTION("SQLAllocHandle() returned unknown error code");
|
||||
}
|
||||
}
|
||||
|
||||
/* for ODBC 1.0 compatibility */
|
||||
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_2("odbc_sql_alloc_connect(): eh:%d\n", eh);
|
||||
|
||||
retval = SQLAllocConnect(ch, &eh);
|
||||
switch (retval)
|
||||
{
|
||||
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
|
||||
return s48_enter_integer((long)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");
|
||||
}
|
||||
}
|
||||
|
||||
/* for ODBC 1.0 compatibility */
|
||||
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_2("odbc_sql_alloc_stmt(): ch:%d\n", ch);
|
||||
|
||||
retval = SQLAllocStmt(ch, &sh);
|
||||
switch (retval)
|
||||
{
|
||||
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
|
||||
return s48_enter_integer((long)sh);
|
||||
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,
|
||||
|
@ -427,7 +406,7 @@ s48_value odbc_sql_data_sources(s48_value env_handle)
|
|||
/* Returns the list of installed drivers and their attributes. */
|
||||
s48_value odbc_sql_drivers(s48_value env_handle)
|
||||
{
|
||||
|
||||
#ifdef (ODBCVER >= 0x0200)
|
||||
SQLHENV eh;
|
||||
SQLRETURN retval;
|
||||
SQLCHAR driver_descr[ODBC_MAX_DRIVER_NAME_LEN];
|
||||
|
@ -488,6 +467,9 @@ s48_value odbc_sql_drivers(s48_value env_handle)
|
|||
|
||||
S48_GC_UNPROTECT();
|
||||
return result;
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x200");
|
||||
#endif /* ODBCVER >= 0x200 */
|
||||
}
|
||||
|
||||
/* Returns information about a specific driver and data source.
|
||||
|
@ -680,6 +662,7 @@ s48_value odbc_sql_set_connect_attr_int(s48_value conn_handle,
|
|||
s48_value attribute,
|
||||
s48_value value)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHDBC ch;
|
||||
SQLINTEGER attr;
|
||||
SQLUINTEGER val;
|
||||
|
@ -715,12 +698,16 @@ s48_value odbc_sql_set_connect_attr_int(s48_value conn_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_set_connect_attr_string(s48_value conn_handle,
|
||||
s48_value attribute,
|
||||
s48_value value)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHDBC ch;
|
||||
SQLINTEGER attr;
|
||||
SQLCHAR *val;
|
||||
|
@ -756,12 +743,15 @@ s48_value odbc_sql_set_connect_attr_string(s48_value conn_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_get_connect_attr_string(s48_value conn_handle,
|
||||
s48_value attribute)
|
||||
{
|
||||
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHDBC ch;
|
||||
SQLINTEGER attr;
|
||||
SQLCHAR *buffer = NULL;
|
||||
|
@ -807,12 +797,15 @@ s48_value odbc_sql_get_connect_attr_string(s48_value conn_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_get_connect_attr_int(s48_value conn_handle,
|
||||
s48_value attribute)
|
||||
{
|
||||
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHDBC ch;
|
||||
SQLINTEGER attr;
|
||||
SQLUINTEGER buffer;
|
||||
|
@ -846,23 +839,26 @@ s48_value odbc_sql_get_connect_attr_int(s48_value conn_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_set_env_attr_int(s48_value env_handle,
|
||||
s48_value attribute,
|
||||
s48_value value)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHENV eh;
|
||||
SQLINTEGER attr;
|
||||
SQLUINTEGER val;
|
||||
SQLRETURN retval;
|
||||
|
||||
ODBC_DEBUG_PRINTF_1("odbc_sql_set_env_attr\n");
|
||||
|
||||
eh = (SQLHENV) s48_extract_integer(env_handle);
|
||||
attr = (SQLINTEGER) s48_extract_integer(attribute);
|
||||
val = (SQLUINTEGER) s48_extract_integer(value);
|
||||
|
||||
ODBC_DEBUG_PRINTF_4("odbc_sql_get_env_attr_int eh %x attr %d value %d\n", eh, attr, val);
|
||||
retval = SQLSetEnvAttr(eh, attr, &val, sizeof(SQLUINTEGER));
|
||||
|
||||
switch (retval)
|
||||
|
@ -887,24 +883,26 @@ s48_value odbc_sql_set_env_attr_int(s48_value env_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_get_env_attr_int(s48_value env_handle,
|
||||
s48_value attribute,
|
||||
s48_value value)
|
||||
{
|
||||
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHENV eh;
|
||||
SQLINTEGER attr;
|
||||
SQLUINTEGER val, str_len;
|
||||
SQLRETURN retval;
|
||||
|
||||
ODBC_DEBUG_PRINTF_1("odbc_sql_get_env_attr_int\n");
|
||||
|
||||
eh = (SQLHENV) s48_extract_integer(env_handle);
|
||||
attr = (SQLINTEGER) s48_extract_integer(attribute);
|
||||
val = (SQLUINTEGER) s48_extract_integer(value);
|
||||
|
||||
ODBC_DEBUG_PRINTF_4("odbc_sql_get_env_attr_int eh %x attr %d value %d\n", eh, attr, val);
|
||||
retval = SQLGetEnvAttr(eh, attr, &val, sizeof(SQLUINTEGER), &str_len);
|
||||
|
||||
switch (retval)
|
||||
|
@ -929,6 +927,9 @@ s48_value odbc_sql_get_env_attr_int(s48_value env_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/* Sets a statement attribute */
|
||||
|
@ -936,7 +937,7 @@ s48_value odbc_sql_set_stmt_attr_int(s48_value stmt_handle,
|
|||
s48_value attribute,
|
||||
s48_value value)
|
||||
{
|
||||
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHSTMT sh;
|
||||
SQLINTEGER attr;
|
||||
SQLUINTEGER val;
|
||||
|
@ -972,12 +973,16 @@ s48_value odbc_sql_set_stmt_attr_int(s48_value stmt_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_set_stmt_attr_string(s48_value stmt_handle,
|
||||
s48_value attribute,
|
||||
s48_value value)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHSTMT sh;
|
||||
SQLINTEGER attr;
|
||||
SQLCHAR *val;
|
||||
|
@ -1013,10 +1018,14 @@ s48_value odbc_sql_set_stmt_attr_string(s48_value stmt_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_get_stmt_attr_int(s48_value stmt_handle, s48_value attribute)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHSTMT sh;
|
||||
SQLINTEGER attr, val, buf_size;
|
||||
SQLRETURN retval;
|
||||
|
@ -1050,12 +1059,15 @@ s48_value odbc_sql_get_stmt_attr_int(s48_value stmt_handle, s48_value attribute)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_get_stmt_attr_string(s48_value stmt_handle,
|
||||
s48_value attribute)
|
||||
{
|
||||
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHSTMT sh;
|
||||
SQLINTEGER attr, buffer_len, buffer_needed;
|
||||
SQLCHAR *buffer = NULL;
|
||||
|
@ -1100,6 +1112,9 @@ s48_value odbc_sql_get_stmt_attr_string(s48_value stmt_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1114,6 +1129,7 @@ s48_value odbc_sql_get_stmt_attr_string(s48_value stmt_handle,
|
|||
s48_value odbc_sql_get_desc_field_int(s48_value desc_handle, s48_value rec_number,
|
||||
s48_value field_id)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHDESC dh;
|
||||
SQLSMALLINT rn, fi;
|
||||
SQLINTEGER value, buffer_len;
|
||||
|
@ -1169,12 +1185,16 @@ s48_value odbc_sql_get_desc_field_int(s48_value desc_handle, s48_value rec_numbe
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/* Returns the value of a single descriptor field (for strings/binary data) */
|
||||
s48_value odbc_sql_get_desc_field_string(s48_value desc_handle, s48_value rec_number,
|
||||
s48_value field_id)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHDESC dh;
|
||||
SQLSMALLINT rn, fi;
|
||||
SQLCHAR *buffer = NULL;
|
||||
|
@ -1228,6 +1248,9 @@ s48_value odbc_sql_get_desc_field_string(s48_value desc_handle, s48_value rec_nu
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1283,7 +1306,7 @@ s48_value odbc_sql_prepare(s48_value stmt_handle, s48_value stmt_txt)
|
|||
s48_value odbc_sql_bind_parameter_exec_out(s48_value stmt_handle,
|
||||
s48_value param_vals)
|
||||
{
|
||||
|
||||
#ifdef (ODBCVER >= 0x200)
|
||||
SQLHSTMT sh;
|
||||
SQLSMALLINT value_type, param_type;
|
||||
SQLRETURN retval;
|
||||
|
@ -1518,7 +1541,9 @@ s48_value odbc_sql_bind_parameter_exec_out(s48_value stmt_handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x200");
|
||||
#endif /* ODBCVER >= 0x200 */
|
||||
}
|
||||
|
||||
s48_value odbc_sql_get_cursor_name(s48_value stmt_handle)
|
||||
|
@ -1985,6 +2010,7 @@ s48_value odbc_sql_set_pos(s48_value stmt_handle, s48_value row_number,
|
|||
update, delete, and fetch by bookmark. */
|
||||
s48_value odbc_sql_bulk_operations(s48_value stmt_handle, s48_value operation)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHSTMT sh;
|
||||
SQLUSMALLINT op;
|
||||
SQLRETURN retval;
|
||||
|
@ -2024,6 +2050,9 @@ s48_value odbc_sql_bulk_operations(s48_value stmt_handle, s48_value operation)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/* Determines whether there are more result sets available and, if so,
|
||||
|
@ -2232,6 +2261,7 @@ s48_value odbc_sql_describe_col(s48_value stmt_handle, s48_value column_number)
|
|||
s48_value odbc_sql_col_attribute(s48_value stmt_handle, s48_value column_number,
|
||||
s48_value field_id)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHSTMT sh;
|
||||
SQLUSMALLINT cn, fi;
|
||||
SQLCHAR *buffer = NULL;
|
||||
|
@ -2294,6 +2324,9 @@ s48_value odbc_sql_col_attribute(s48_value stmt_handle, s48_value column_number,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
|
||||
|
@ -3140,6 +3173,7 @@ s48_value odbc_sql_free_statement(s48_value stmt_handle, s48_value option)
|
|||
/* Closes a cursor that has been opened on a statement handle */
|
||||
s48_value odbc_sql_close_cursor(s48_value stmt_handle)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLHSTMT sh;
|
||||
SQLRETURN retval;
|
||||
|
||||
|
@ -3169,6 +3203,9 @@ s48_value odbc_sql_close_cursor(s48_value stmt_handle)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/* Cancels an SQL statement */
|
||||
|
@ -3209,6 +3246,7 @@ s48_value odbc_sql_cancel(s48_value stmt_handle)
|
|||
s48_value odbc_sql_endtran(s48_value handle_type, s48_value handle,
|
||||
s48_value completion_type)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLSMALLINT ht, ct;
|
||||
SQLHANDLE h;
|
||||
SQLRETURN retval;
|
||||
|
@ -3243,6 +3281,9 @@ s48_value odbc_sql_endtran(s48_value handle_type, s48_value handle,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3292,6 +3333,7 @@ s48_value odbc_sql_disconnect(s48_value conn_handle)
|
|||
/* Free a handle */
|
||||
s48_value odbc_sql_free_handle(s48_value handle_type, s48_value handle)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLSMALLINT ht;
|
||||
SQLHANDLE h;
|
||||
SQLRETURN retval;
|
||||
|
@ -3324,6 +3366,9 @@ s48_value odbc_sql_free_handle(s48_value handle_type, s48_value handle)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3336,6 +3381,7 @@ s48_value odbc_sql_free_handle(s48_value handle_type, s48_value handle)
|
|||
|
||||
s48_value odbc_sql_get_diag_recs(s48_value handle_type, s48_value handle)
|
||||
{
|
||||
#ifdef (ODBCVER >= 0x300)
|
||||
SQLSMALLINT ht;
|
||||
SQLHANDLE h;
|
||||
SQLCHAR sql_state[6];
|
||||
|
@ -3411,6 +3457,9 @@ s48_value odbc_sql_get_diag_recs(s48_value handle_type, s48_value handle)
|
|||
S48_GC_UNPROTECT(); /* res */
|
||||
free(buffer);
|
||||
return res;
|
||||
#else
|
||||
ODBC_RAISE_EXCEPTION("ODBC driver manager API version not >= 0x300");
|
||||
#endif /* ODBCVER >= 0x300 */
|
||||
}
|
||||
|
||||
#ifdef ODBC_DEBUG_MSGS
|
||||
|
@ -3721,10 +3770,6 @@ void s48_init_odbc(void)
|
|||
S48_EXPORT_FUNCTION(odbc_alloc_environment_handle);
|
||||
S48_EXPORT_FUNCTION(odbc_alloc_connection_handle);
|
||||
S48_EXPORT_FUNCTION(odbc_alloc_statement_handle);
|
||||
/* ODBC 1.0 compatibility */
|
||||
S48_EXPORT_FUNCTION(odbc_sql_alloc_env);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_alloc_connect);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_alloc_stmt);
|
||||
|
||||
S48_EXPORT_FUNCTION(odbc_sql_connect);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_browse_connect);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#define ODBC_RETVAL_BUFFER_INITIAL_SIZE 3
|
||||
|
||||
/* turn debug messages on/off. */
|
||||
#define ODBC_DEBUG_MSGS 1
|
||||
|
||||
#define ODBC_RAISE_EXCEPTION(MSG) s48_raise_string_os_error(MSG)
|
||||
|
@ -178,11 +179,6 @@ 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,
|
||||
|
|
|
@ -540,33 +540,6 @@
|
|||
(conn-handle connection-string)
|
||||
"odbc_sql_browse_connect")
|
||||
|
||||
;;; for ODBC 1.0 compatibility
|
||||
(define (odbc10-sql-alloc-env)
|
||||
(really-make-environment-handle (odbc10-sql-alloc-env-internal)))
|
||||
|
||||
(import-lambda-definition odbc10-sql-alloc-env-internal
|
||||
()
|
||||
"odbc_sql_alloc_env")
|
||||
|
||||
(define (odbc10-sql-alloc-connect env-handle)
|
||||
(check-arg environment-handle? env-handle odbc10-sql-alloc-connect)
|
||||
(really-make-connection-handle
|
||||
(odbc10-sql-alloc-connect-internal (environment-handle-handle env-handle)) env-handle #f))
|
||||
|
||||
(import-lambda-definition odbc10-sql-alloc-connect-internal
|
||||
(env-handle)
|
||||
"odbc_sql_alloc_env_handle")
|
||||
|
||||
(define (odbc10-sql-alloc-stmt conn-handle)
|
||||
(check-arg connection-handle? conn-handle odbc10-sql-alloc-stmt)
|
||||
(really-make-statement-handle
|
||||
(odbc10-sql-alloc-stmt-internal (connection-handle-handle conn-handle))
|
||||
conn-handle))
|
||||
|
||||
(import-lambda-definition odbc10-sql-alloc-stmt-internal
|
||||
(conn-handle)
|
||||
"odbc_sql_alloc_stmt_handle")
|
||||
|
||||
;;; PART 2
|
||||
|
||||
(define (odbc-sql-data-sources env-handle)
|
||||
|
|
Loading…
Reference in New Issue