Support for SQLSetPos() (odbc-sql-set-pos) and SQLBulkOperations()
(odbc-sql-bulk-operations)
This commit is contained in:
parent
7ddfc3211c
commit
78b653e815
102
scsh/odbc/odbc.c
102
scsh/odbc/odbc.c
|
@ -1517,6 +1517,106 @@ void check_sql_get_data_result(SQLRETURN retval, SQLHSTMT stmt_handle)
|
|||
}
|
||||
}
|
||||
|
||||
/* Positions a cursor within a fetched block of data and allows an application
|
||||
to refresh data in the rowset or to update or delete data in the result
|
||||
set */
|
||||
s48_value odbc_sql_set_pos(s48_value stmt_handle, s48_value row_number,
|
||||
s48_value operation, s48_value lock_type)
|
||||
{
|
||||
SQLHSTMT sh;
|
||||
SQLUSMALLINT rn, op, lt;
|
||||
SQLRETURN retval;
|
||||
|
||||
ODBC_DEBUG_PRINTF("odbc_sql_set_pos\n");
|
||||
|
||||
sh = (SQLHSTMT) s48_extract_integer(stmt_handle);
|
||||
rn = (SQLUSMALLINT) s48_extract_integer(row_number);
|
||||
op = (SQLUSMALLINT) s48_extract_integer(operation);
|
||||
lt = (SQLUSMALLINT) s48_extract_integer(lock_type);
|
||||
|
||||
retval = SQLSetPos(sh, rn, op, lt);
|
||||
|
||||
switch (retval)
|
||||
{
|
||||
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
|
||||
{
|
||||
return S48_TRUE;
|
||||
}
|
||||
case SQL_NEED_DATA:
|
||||
{
|
||||
return s48_enter_integer(SQL_NEED_DATA);
|
||||
}
|
||||
case SQL_STILL_EXECUTING:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLSetPos returned SQL_STILL_EXECUTING. Not implemented");
|
||||
break;
|
||||
}
|
||||
case SQL_ERROR:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLSetPos returned SQL_ERROR");
|
||||
break;
|
||||
}
|
||||
case SQL_INVALID_HANDLE:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLSetPos got invalid handle");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLSetPos returned unknown error code");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Performs bulk insertions and bulk bookmark operations, including
|
||||
update, delete, and fetch by bookmark. */
|
||||
s48_value odbc_sql_bulk_operations(s48_value stmt_handle, s48_value operation)
|
||||
{
|
||||
SQLHSTMT sh;
|
||||
SQLUSMALLINT op;
|
||||
SQLRETURN retval;
|
||||
|
||||
ODBC_DEBUG_PRINTF("odbc_sql_bulk_operations\n");
|
||||
|
||||
sh = (SQLHSTMT) s48_extract_integer(stmt_handle);
|
||||
op = (SQLUSMALLINT) s48_extract_integer(operation);
|
||||
|
||||
retval = SQLBulkOperations(sh, op);
|
||||
|
||||
switch (retval)
|
||||
{
|
||||
case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO:
|
||||
{
|
||||
return S48_TRUE;
|
||||
}
|
||||
case SQL_NEED_DATA:
|
||||
{
|
||||
return s48_enter_integer(SQL_NEED_DATA);
|
||||
}
|
||||
case SQL_STILL_EXECUTING:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLBulkOperations returned SQL_STILL_EXECUTING. Not implemented");
|
||||
break;
|
||||
}
|
||||
case SQL_ERROR:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLBulkOperations returned SQL_ERROR");
|
||||
break;
|
||||
}
|
||||
case SQL_INVALID_HANDLE:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLBulkOperations got invalid handle");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ODBC_RAISE_EXCEPTION("SQLBulkOperations returned unknown error code");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s48_value odbc_sql_fetch(s48_value stmt_handle)
|
||||
{
|
||||
|
||||
|
@ -2743,6 +2843,8 @@ void s48_init_odbc(void)
|
|||
/* PART 7 */
|
||||
S48_EXPORT_FUNCTION(odbc_sql_row_count);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_get_data);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_set_pos);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_bulk_operations);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_fetch);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_num_result_cols);
|
||||
S48_EXPORT_FUNCTION(odbc_sql_describe_col);
|
||||
|
|
|
@ -237,6 +237,17 @@ s48_value odbc_sql_get_data(s48_value stmt_handle,
|
|||
s48_value column_number,
|
||||
s48_value target_type);
|
||||
|
||||
/* Positions a cursor within a fetched block of data and allows an application
|
||||
to refresh data in the rowset or to update or delete data in the result
|
||||
set */
|
||||
s48_value odbc_sql_set_pos(s48_value stmt_handle, s48_value row_number,
|
||||
s48_value operation, s48_value lock_type);
|
||||
|
||||
/* Performs bulk insertions and bulk bookmark operations, including
|
||||
update, delete, and fetch by bookmark. */
|
||||
s48_value odbc_sql_bulk_operations(s48_value stmt_handle, s48_value operation);
|
||||
|
||||
|
||||
void check_sql_get_data_result(SQLRETURN retval, SQLHSTMT stmt_handle);
|
||||
|
||||
s48_value odbc_sql_fetch(s48_value stmt_handle);
|
||||
|
|
|
@ -388,6 +388,23 @@
|
|||
(define sql-ensure 1)
|
||||
(define sql-quick 0)
|
||||
|
||||
; possible operation arguments for SQLSetPos() (odbc-sql-set-pos)
|
||||
(define sql-position 0)
|
||||
(define sql-refresh 1)
|
||||
(define sql-update 2)
|
||||
(define sql-delete 3)
|
||||
|
||||
; possible lock-type arguments for SQLSetPos() (odbc-sql-set-pos)
|
||||
(define sql-lock-no-change 0)
|
||||
(define sql-lock-exclusive 1)
|
||||
(define sql-lock-unlock 2)
|
||||
|
||||
; possible operation arguments for SQLBulkOperations() (odbc-sql-bulk-operations)
|
||||
(define sql-add 4)
|
||||
(define sql-update-by-bookmark 5)
|
||||
(define sql-delete-by-bookmark 6)
|
||||
(define sql-fetch-by-bookmark 7)
|
||||
|
||||
;;; ODBC return values
|
||||
(define sql-error -1)
|
||||
(define sql-success 0)
|
||||
|
@ -660,6 +677,24 @@
|
|||
(stmt-handle column-number target-type)
|
||||
"odbc_sql_get_data")
|
||||
|
||||
(define (odbc-sql-set-pos stmt-handle row-number operation lock-type)
|
||||
(check-arg statement-handle? stmt-handle odbc-sql-set-pos)
|
||||
(odbc-sql-set-pos-internal (statement-handle-handle stmt-handle)
|
||||
row-number operation lock-type))
|
||||
|
||||
(import-lambda-definition odbc-sql-set-pos-internal
|
||||
(stmt-handle row-number operation lock-type)
|
||||
"odbc_sql_set_pos")
|
||||
|
||||
(define (odbc-sql-bulk-operations stmt-handle operation)
|
||||
(check-arg statement-handle? stmt-handle odbc-sql-bulk-operations)
|
||||
(odbc-sql-bulk-operations-internal (statement-handle-handle stmt-handle)
|
||||
operation))
|
||||
|
||||
(import-lambda-definition odbc-sql-bulk-operations-internal
|
||||
(stmt-handle operation)
|
||||
"odbc_sql_bulk_operations")
|
||||
|
||||
(define (odbc-sql-fetch stmt-handle)
|
||||
(check-arg statement-handle-handle stmt-handle odbc-sql-fetch)
|
||||
(odbc-sql-fetch-internal (statement-handle-handle stmt-handle)))
|
||||
|
|
Loading…
Reference in New Issue