Support for SQLGetCursorName() and SQLSetCursorName()

This commit is contained in:
eknauel 2002-09-03 13:44:06 +00:00
parent 3d7f50ada2
commit f0fdf618fe
3 changed files with 101 additions and 5 deletions

View File

@ -1224,6 +1224,79 @@ s48_value odbc_sql_bind_parameter_exec_out(s48_value stmt_handle,
}
s48_value odbc_sql_get_cursor_name(s48_value stmt_handle)
{
SQLHSTMT sh;
SQLRETURN retval;
SQLCHAR cursorname[ODBC_MAX_CURSOR_NAME_STR_LEN];
SQLSMALLINT buffer_len;
ODBC_DEBUG_PRINTF("odbc_sql_get_cursor_name\n");
sh = (SQLHSTMT) s48_extract_integer(stmt_handle);
retval = SQLGetCursorName(sh, cursorname, ODBC_MAX_CURSOR_NAME_STR_LEN - 1, &buffer_len);
switch (retval)
{
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
{
return s48_enter_string(cursorname);
}
case SQL_ERROR:
{
ODBC_RAISE_EXCEPTION("SQLGetCursorName returned SQL_ERROR");
break;
}
case SQL_INVALID_HANDLE:
{
ODBC_RAISE_EXCEPTION("SQLGetCursorName got invalid handle");
break;
}
default:
{
ODBC_RAISE_EXCEPTION("SQLGetCursorName returned unknown error code");
break;
}
}
}
void odbc_sql_set_cursor_name(s48_value stmt_handle, s48_value cursorname)
{
SQLHSTMT sh;
SQLCHAR *cn;
SQLRETURN retval;
ODBC_DEBUG_PRINTF("odbc_sql_set_cursor_name\n");
sh = (SQLHSTMT) s48_extract_integer(stmt_handle);
cn = (SQLCHAR *) s48_extract_string(cursorname);
retval = SQLSetCursorName(sh, cn, S48_STRING_LENGTH(cursorname));
switch (retval)
{
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
{
return;
}
case SQL_ERROR:
{
ODBC_RAISE_EXCEPTION("SQLSetCursorName returned SQL_ERROR");
break;
}
case SQL_INVALID_HANDLE:
{
ODBC_RAISE_EXCEPTION("SQLSetCursorName got invalid handle");
break;
}
default:
{
ODBC_RAISE_EXCEPTION("SQLSetCursorName returned unknown error code");
break;
}
}
}
/*
*
@ -1460,10 +1533,10 @@ s48_value odbc_sql_num_result_cols(s48_value stmt_handle)
SQLSMALLINT numcols;
SQLRETURN retval;
ODBC_DEBUG_PRINTF("odbc_sql_num_result_cols\n");
sh = (SQLHSTMT) s48_extract_integer(stmt_handle);
ODBC_DEBUG_PRINTF("odbc_sql_num_result_cols\n");
retval = SQLNumResultCols(sh, &numcols);
switch (retval)
@ -2101,6 +2174,8 @@ void s48_init_odbc(void)
/* PART 5 */
S48_EXPORT_FUNCTION(odbc_sql_prepare);
S48_EXPORT_FUNCTION(odbc_sql_bind_parameter_exec_out);
S48_EXPORT_FUNCTION(odbc_sql_get_cursor_name);
S48_EXPORT_FUNCTION(odbc_sql_set_cursor_name);
/* PART 6 */
S48_EXPORT_FUNCTION(odbc_sql_execute);

View File

@ -13,6 +13,7 @@
#define ODBC_GET_STMT_ATTR_MAX_LEN 255
#define ODBC_GET_DATA_MAX_STR_LEN 255
#define ODBC_DESCRIBE_COL_MAX_STR_LEN 255
#define ODBC_MAX_CURSOR_NAME_STR_LEN 255
#define ODBC_DEBUG_MSGS 1
@ -205,7 +206,11 @@ s48_value odbc_sql_get_stmt_attr_string(s48_value stmt_handle,
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);
s48_value param_vals);
s48_value odbc_sql_get_cursor_name(s48_value stmt_handle);
void odbc_sql_set_cursor_name(s48_value stmt_handle, s48_value cursorname);
/*
*

View File

@ -576,7 +576,7 @@
"odbc_sql_prepare")
(define (odbc-sql-bind-parameter-exec-out stmt-handle param-vals)
(check-arg statement-handle-handle stmt-handle odbc-sql-bind-parameter-exec-out)
(check-arg statement-handle? stmt-handle odbc-sql-bind-parameter-exec-out)
(odbc-sql-bind-parameter-exec-out-internal (statement-handle-handle stmt-handle)
param-vals))
@ -584,6 +584,22 @@
(stmt-handle param-vals)
"odbc_sql_bind_parameter_exec_out")
(define (odbc-sql-get-cursor-name stmt-handle)
(check-arg statement-handle? stmt-handle odbc-sql-get-cursor-name)
(odbc-sql-get-cursor-name-internal (statement-handle-handle stmt-handle)))
(import-lambda-definition odbc-sql-get-cursor-name-internal
(stmt-handle)
"odbc_sql_get_cursor_name")
(define (odbc-sql-set-cursor-name stmt-handle cursor-name)
(check-arg statement-handle? stmt-handle odbc-sql-set-cursor-name)
(odbc-sql-set-cursor-name-internal (statement-handle-handle stmt-handle) cursor-name))
(import-lambda-definition odbc-sql-set-cursor-name-internal
(stmt-handle cursor-name)
"odbc_sql_set_cursor_name")
;;; PART 6
(define (odbc-sql-execute stmt-handle)
@ -653,7 +669,7 @@
(define (odbc-sql-num-result-cols stmt-handle)
(check-arg statement-handle? stmt-handle odbc-sql-num-result-cols)
(odbc-sql-num-result-cols (statement-handle-handle stmt-handle)))
(odbc-sql-num-result-cols-internal (statement-handle-handle stmt-handle)))
(import-lambda-definition odbc-sql-num-result-cols-internal
(stmt-handle)