- rewrote exception handling system, pass ODBC status codes to Scheme

directly. This leads to multiple return values in some cases.

- new condition types

- raise conditions only in case of fatal errors

- rewrote odbc_sql_data_sources() and odbc_sql_drivers()

- removed hardcoded ODBC_RETVAL_BUFFER_INITIAL_SIZE, the return value
  buffer size can now be read/set from Scheme.

- removed odbc_sql_bind_parameter_exec_out(), which is a poor
  implementation of a SQLBindParameter() binding. TODO: make a
  better one.

- use the p.c. SQL_SUCCEEDED()

- rewrote odbc_sql_get_data(): Resize return buffer value if necessary

- new modules: low-odbc (functions), low-odbc-constants (constants)

- major code cleanup
This commit is contained in:
eknauel 2003-04-24 13:02:02 +00:00
parent 750de51339
commit ad8131edad
9 changed files with 2226 additions and 2360 deletions

View File

@ -22,17 +22,18 @@ RCS file: /cvsroot/scsh/scsh-0.6/autogen.sh,v
retrieving revision 1.7 retrieving revision 1.7
diff -u -r1.7 autogen.sh diff -u -r1.7 autogen.sh
--- autogen.sh 12 Feb 2002 16:26:05 -0000 1.7 --- autogen.sh 12 Feb 2002 16:26:05 -0000 1.7
+++ autogen.sh 20 Mar 2003 16:01:57 -0000 +++ autogen.sh 23 Apr 2003 15:23:43 -0000
@@ -2,7 +2,7 @@ @@ -2,7 +2,8 @@
autoheader && autoheader &&
autoconf && autoconf &&
-./configure && -./configure &&
+./configure --with-iODBC=/usr/lib && +./configure --with-iODBC=/afs/wsi/i386_fbsd46 &&
+##./configure --with-iODBC=/usr/lib &&
touch scsh/*.c && touch scsh/*.c &&
touch build/filenames.scm && touch build/filenames.scm &&
rm -f scheme48.image cig/cig.image scsh/scsh.image && rm -f scheme48.image cig/cig.image scsh/scsh.image &&
@@ -12,5 +12,4 @@ @@ -12,5 +13,4 @@
make i-know-what-i-am-doing && make i-know-what-i-am-doing &&
make c/scheme48.h&& make c/scheme48.h&&
make linker && make linker &&
@ -42,11 +43,11 @@ diff -u -r1.7 autogen.sh
Index: configure.in Index: configure.in
=================================================================== ===================================================================
RCS file: /cvsroot/scsh/scsh-0.6/configure.in,v RCS file: /cvsroot/scsh/scsh-0.6/configure.in,v
retrieving revision 1.27 retrieving revision 1.28
diff -u -r1.27 configure.in diff -u -r1.28 configure.in
--- configure.in 13 Dec 2002 15:22:13 -0000 1.27 --- configure.in 16 Apr 2003 12:41:36 -0000 1.28
+++ configure.in 20 Mar 2003 16:01:57 -0000 +++ configure.in 23 Apr 2003 15:23:43 -0000
@@ -394,7 +394,30 @@ @@ -373,7 +373,30 @@
AC_SUBST(LIBS) AC_SUBST(LIBS)
AC_SUBST(TMPDIR) AC_SUBST(TMPDIR)
@ -65,12 +66,12 @@ diff -u -r1.27 configure.in
+ +
+AC_ARG_WITH(iODBC, +AC_ARG_WITH(iODBC,
+ [ --with-iODBC=DIR Support for iODBC ], + [ --with-iODBC=DIR Support for iODBC ],
+ [ with_iodbc=$with_iodbc ], + [ with_iodbc=$withval ],
+ [ with_iodbc=no ] + [ with_iodbc=no ]
+ ) + )
+if test "$with_iodbc" != no; then +if test "$with_iodbc" != no; then
+ odbc_includes="-I$with_iodbc/include" + odbc_includes="-I$withval/include"
+ odbc_libs="-liodbc -L$with_iodbc/lib" + odbc_libs="-liodbc -L$withval/lib"
+ AC_SUBST(odbc_includes) + AC_SUBST(odbc_includes)
+ AC_SUBST(odbc_libs) + AC_SUBST(odbc_libs)
+fi +fi
@ -81,10 +82,10 @@ diff -u -r1.27 configure.in
Index: Makefile.in Index: Makefile.in
=================================================================== ===================================================================
RCS file: /cvsroot/scsh/scsh-0.6/Makefile.in,v RCS file: /cvsroot/scsh/scsh-0.6/Makefile.in,v
retrieving revision 1.59 retrieving revision 1.61
diff -u -r1.59 Makefile.in diff -u -r1.61 Makefile.in
--- Makefile.in 13 Jan 2003 06:17:49 -0000 1.59 --- Makefile.in 10 Mar 2003 12:13:02 -0000 1.61
+++ Makefile.in 20 Mar 2003 16:01:57 -0000 +++ Makefile.in 23 Apr 2003 15:23:43 -0000
@@ -8,8 +8,8 @@ @@ -8,8 +8,8 @@
VPATH = @srcdir@ VPATH = @srcdir@
CC = @CC@ CC = @CC@
@ -101,8 +102,8 @@ diff -u -r1.59 Makefile.in
# out of the CVS repository. # out of the CVS repository.
# We cannot use Scsh here since -i is not understood. # We cannot use Scsh here since -i is not understood.
-BUILD_RUNNABLE = /afs/wsi/i386_fbsd32/bin/scheme48 -BUILD_RUNNABLE = /afs/wsi/i386_fbsd32/bin/scheme48
+BUILD_RUNNABLE = /afs/wsi/ppc_macx55/scheme48-0.53/bin/scheme48
+#BUILD_RUNNABLE = /afs/wsi/ppc_macx55/scheme48-0.53/bin/scheme48 +#BUILD_RUNNABLE = /afs/wsi/ppc_macx55/scheme48-0.53/bin/scheme48
+BUILD_RUNNABLE = /afs/wsi/i386_fbsd32/scheme48-0.53/bin/scheme48
RUNNABLE = scsh RUNNABLE = scsh
MANPAGE = $(RUNNABLE).$(manext) MANPAGE = $(RUNNABLE).$(manext)
LIB = $(libdir)/$(RUNNABLE) LIB = $(libdir)/$(RUNNABLE)
@ -141,175 +142,34 @@ diff -u -r1.59 Makefile.in
# Socket rules # Socket rules
c/unix/socket.o: c/scheme48.h c/fd-io.h c/event.h c/unix/socket.o: c/scheme48.h c/fd-io.h c/event.h
@@ -835,7 +843,8 @@ @@ -837,7 +845,10 @@
scsh/rx/re-high.scm \ scsh/rx/re-high.scm \
scsh/rx/regexp.scm \ scsh/rx/regexp.scm \
scsh/rx/re-low.scm \ scsh/rx/re-low.scm \
- scsh/rx/regress.scm - scsh/rx/regress.scm
+ scsh/rx/regress.scm \ + scsh/rx/regress.scm \
+ scsh/odbc/odbc-interfaces.scm \
+ scsh/odbc/odbc-packages.scm \
+ scsh/odbc/odbc.scm + scsh/odbc/odbc.scm
# scsh/dbm.scm db.scm ndbm.scm # scsh/dbm.scm db.scm ndbm.scm
# jcontrol # jcontrol
@@ -861,7 +872,9 @@
$(srcdir)/scsh/rx/packages.scm \
$(srcdir)/scsh/scsh-package.scm \
$(srcdir)/scsh/lib/ccp-pack.scm \
- $(srcdir)/scsh/lib/char-package.scm
+ $(srcdir)/scsh/lib/char-package.scm \
+ $(srcdir)/scsh/odbc/odbc-interfaces.scm \
+ $(srcdir)/scsh/odbc/odbc-packages.scm
opens = floatnums scsh ccp-lib scsh-top-package scsh-here-string-hax \
srfi-1 srfi-13 srfi-14 # srfi-14 is also exported by scsh
This will add some rules to Makefile and add two options to configure: This will add some rules to Makefile and add two options to configure:
--with-iODBC=PATH and --with-unixODBC=PATH. --with-iODBC=PATH and --with-unixODBC=PATH.
This patch will add a module odbc to the package configuration. With
this patch, it's possible to type ,open odbc at the scsh prompt to
load all the beautiful ODBC functions into scsh:
Index: scsh-package.scm
===================================================================
RCS file: /cvsroot/scsh/scsh-0.6/scsh/scsh-package.scm,v
retrieving revision 1.59
diff -u -r1.59 scsh-package.scm
--- scsh-package.scm 25 Feb 2003 12:58:37 -0000 1.59
+++ scsh-package.scm 20 Mar 2003 16:03:38 -0000
@@ -597,3 +597,21 @@
signals
srfi-9)
(files srfi-19))
+
+;;; ODBC stuff
+
+(define-structure odbc-data-types odbc-data-types-interface
+ (open
+ scheme define-structure
+ external-calls)
+ (files (odbc odbc-types)))
+
+(define-structure odbc odbc-interface
+ (open
+ scheme define-record-types
+ external-calls
+ scsh-utilities
+ conditions signals)
+ (files (odbc odbc)
+ (odbc odbc-bindcol)))
+
Index: scsh-interfaces.scm
===================================================================
RCS file: /cvsroot/scsh/scsh-0.6/scsh/scsh-interfaces.scm,v
retrieving revision 1.53
diff -u -r1.53 scsh-interfaces.scm
--- scsh-interfaces.scm 25 Feb 2003 12:58:37 -0000 1.53
+++ scsh-interfaces.scm 20 Mar 2003 16:03:39 -0000
@@ -1166,13 +1166,13 @@
(export crypt))
(define-interface uname-interface
- (export uname
- uname:os-name
- uname:node-name
- uname:release
- uname:version
- uname:machine
- type/uname))
+ (export uname
+ uname:os-name
+ uname:node-name
+ uname:release
+ uname:version
+ uname:machine
+ type/uname))
(define-interface md5-interface
(export make-md5-context
@@ -1275,3 +1275,92 @@
;; Date to string/string to date converters.
date->string
string->date))
+
+;;; ODBC stuff
+(define-interface odbc-data-types-interface
+ (export
+
+ make-sql-date
+ sql-date?
+ sql-date-year
+ sql-date-month
+ sql-date-day
+
+ make-sql-time
+ sql-time?
+ sql-time-hour
+ sql-time-minute
+ sql-time-second
+
+ make-sql-timestamp
+ sql-timestamp?
+ sql-timestamp-year
+ sql-timestamp-month
+ sql-timestamp-day
+ sql-timestamp-hour
+ sql-timestamp-minute
+ sql-timestamp-second
+ sql-timestamp-fraction
+
+ make-sql-numeric
+ sql-numeric?
+ sql-numeric-precision
+ sql-numeric-scale
+ sql-numeric-sign
+ sql-numeric-value))
+
+(define-interface odbc-interface
+ (export
+ odbc-handle?
+ environment-handle?
+ connection-handle?
+ statement-handle?
+ descriptor-handle?
+
+ odbc-alloc-environment-handle
+ odbc-alloc-connection-handle
+ odbc-alloc-statement-handle
+ odbc-sql-connect
+
+ odbc-sql-data-sources
+ odbc-sql-drivers
+ odbc-sql-get-info-int
+ odbc-sql-get-info-string
+ odbc-sql-get-func
+ odbc-sql-get-type-info
+
+ odbc-sql-set-connect-attr-int
+ odbc-sql-set-connect-attr-string
+ odbc-sql-get-connect-attr-string
+ odbc-sql-get-connect-attr-int
+ odbc-sql-set-env-attr-int
+ odbc-sql-get-env-attr-int
+ odbc-sql-set-stmt-attr-int
+ odbc-sql-get-stmt-attr-int
+
+ odbc-sql-prepare
+ odbc-sql-bind-parameter-exec-out
+ odbc-sql-get-cursor-name
+ odbc-sql-set-cursor-name
+
+ odbc-sql-execute
+ odbc-sql-execute-direct
+
+ odbc-sql-row-count
+ odbc-sql-get-data
+ odbc-sql-fetch
+
+ odbc-sql-free-statement
+ odbc-sql-close-cursor
+ odbc-sql-cancel
+ odbc-sql-num-result-cols
+ odbc-sql-describe-col
+
+ odbc-sql-disconnect
+ odbc-sql-free-handle
+
+ odbc-buffer-exceeded?
+ signal-buffer-exceeded
+ odbc-unbound-column?
+ signal-unbound-column
+ odbc-sql-bindcol))
Now it's time to build scsh. Edit the call to configure in autgen.sh to Now it's time to build scsh. Edit the call to configure in autgen.sh to
your needs, e.g.: your needs, e.g.:

View File

@ -1,3 +1,5 @@
; ,open srfi-13
(define (pretty-print-constant str) (define (pretty-print-constant str)
(string-map (string-map
(lambda (c) (if (char=? c #\_) #\- c)) (lambda (c) (if (char=? c #\_) #\- c))
@ -23,20 +25,30 @@
(else (else
(error "don't know this type " type))))) (error "don't know this type " type)))))
(define (generate-constant-list c-name scheme-name type)
(let ((real-scheme-name (or scheme-name (pretty-print-constant c-name))))
(format (current-output-port) "\t ~A\\n" real-scheme-name)))
(define (generate-comment str) (define (generate-comment str)
(format (current-output-port) (format (current-output-port)
"printf(\"\\n\\n~A\\n\");~%" str)) "printf(\"\\n\\n~A\\n\");~%" str))
(define (generate-constants const-list) (define (do-with-constants const-list print-func)
(map (map
(lambda (thing) (lambda (thing)
(cond ((string? thing) (generate-comment thing)) (cond ((string? thing) (generate-comment thing))
((list? thing) ((list? thing)
(generate-print-func (car thing) (cadr thing) (caddr thing))) (print-func (car thing) (cadr thing) (caddr thing)))
(else (else
(error "Don't know what to do with this " thing)))) (error "Don't know what to do with this " thing))))
const-list)) const-list))
(define (generate-constants const-list)
(do-with-constants const-list generate-constants))
(define (generate-list-of-constants const-list)
(do-with-constants const-list generate-constant-list))
(define odbc-constants-from-sql-h (define odbc-constants-from-sql-h
'(";;; some return values" '(";;; some return values"
("SQL_NULL_DATA" #f dec) ("SQL_NULL_DATA" #f dec)
@ -1685,3 +1697,9 @@
(generate-constants odbc-constants-from-sqlext-h) (generate-constants odbc-constants-from-sqlext-h)
(close-output-port (current-output-port)))) (close-output-port (current-output-port))))
(with-output-to-file "constants.txt"
(lambda ()
(for-each (lambda (name)
(format (current-output-port) "\t~A~%" name))
clist)
(close-output-port (current-output-port))))

View File

@ -1691,12 +1691,6 @@
(define sql-table-stat 0) (define sql-table-stat 0)
;;; Defines for SQLTables
(define sql-all-catalogs %)
(define sql-all-schemas %)
(define sql-all-table-types %)
;;; Options for SQLDriverConnect ;;; Options for SQLDriverConnect
(define sql-driver-noprompt 0) (define sql-driver-noprompt 0)
(define sql-driver-complete 1) (define sql-driver-complete 1)
@ -1757,7 +1751,3 @@
(define sql-pt-unknown 0) (define sql-pt-unknown 0)
(define sql-pt-procedure 1) (define sql-pt-procedure 1)
(define sql-pt-function 2) (define sql-pt-function 2)
;;; This define is too large for RC (very funny!!!)
(define sql-odbc-keywords ABSOLUTE,ACTION,ADA,ADD,ALL,ALLOCATE,ALTER,AND,ANY,ARE,AS,ASC,ASSERTION,AT,AUTHORIZATION,AVG,BEGIN,BETWEEN,BIT,BIT_LENGTH,BOTH,BY,CASCADE,CASCADED,CASE,CAST,CATALOG,CHAR,CHAR_LENGTH,CHARACTER,CHARACTER_LENGTH,CHECK,CLOSE,COALESCE,COLLATE,COLLATION,COLUMN,COMMIT,CONNECT,CONNECTION,CONSTRAINT,CONSTRAINTS,CONTINUE,CONVERT,CORRESPONDING,COUNT,CREATE,CROSS,CURRENT,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,CURSOR,DATE,DAY,DEALLOCATE,DEC,DECIMAL,DECLARE,DEFAULT,DEFERRABLE,DEFERRED,DELETE,DESC,DESCRIBE,DESCRIPTOR,DIAGNOSTICS,DISCONNECT,DISTINCT,DOMAIN,DOUBLE,DROP,ELSE,END,END-EXEC,ESCAPE,EXCEPT,EXCEPTION,EXEC,EXECUTE,EXISTS,EXTERNAL,EXTRACT,FALSE,FETCH,FIRST,FLOAT,FOR,FOREIGN,FORTRAN,FOUND,FROM,FULL,GET,GLOBAL,GO,GOTO,GRANT,GROUP,HAVING,HOUR,IDENTITY,IMMEDIATE,IN,INCLUDE,INDEX,INDICATOR,INITIALLY,INNER,INPUT,INSENSITIVE,INSERT,INT,INTEGER,INTERSECT,INTERVAL,INTO,IS,ISOLATION,JOIN,KEY,LANGUAGE,LAST,LEADING,LEFT,LEVEL,LIKE,LOCAL,LOWER,MATCH,MAX,MIN,MINUTE,MODULE,MONTH,NAMES,NATIONAL,NATURAL,NCHAR,NEXT,NO,NONE,NOT,NULL,NULLIF,NUMERIC,OCTET_LENGTH,OF,ON,ONLY,OPEN,OPTION,OR,ORDER,OUTER,OUTPUT,OVERLAPS,PAD,PARTIAL,PASCAL,PLI,POSITION,PRECISION,PREPARE,PRESERVE,PRIMARY,PRIOR,PRIVILEGES,PROCEDURE,PUBLIC,READ,REAL,REFERENCES,RELATIVE,RESTRICT,REVOKE,RIGHT,ROLLBACK,ROWSSCHEMA,SCROLL,SECOND,SECTION,SELECT,SESSION,SESSION_USER,SET,SIZE,SMALLINT,SOME,SPACE,SQL,SQLCA,SQLCODE,SQLERROR,SQLSTATE,SQLWARNING,SUBSTRING,SUM,SYSTEM_USER,TABLE,TEMPORARY,THEN,TIME,TIMESTAMP,TIMEZONE_HOUR,TIMEZONE_MINUTE,TO,TRAILING,TRANSACTION,TRANSLATE,TRANSLATION,TRIM,TRUE,UNION,UNIQUE,UNKNOWN,UPDATE,UPPER,USAGE,USER,USING,VALUE,VALUES,VARCHAR,VARYING,VIEW,WHEN,WHENEVER,WHERE,WITH,WORK,WRITE,YEAR,ZONE)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
(define-structure low-odbc low-odbc-interface
(open
scheme external-calls scsh-utilities
define-record-types
conditions signals)
(files
odbc))
(define-structure low-odbc-constants low-odbc-constants-interface
(open scheme)
(files
odbc-constants))

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@
#include <stdio.h> #include <stdio.h>
/* ODBC header files */ /* ODBC header files */
#include <sql.h> #include <sql.h>
#include <sqlext.h> #include <sqlext.h>
#include <sqltypes.h> #include <sqltypes.h>
@ -14,24 +13,9 @@
#define ERROR_MSG_BUFFER_LEN 255 #define ERROR_MSG_BUFFER_LEN 255
#define ODBC_MAX_STR_LEN 255
#define ODBC_MAX_DRIVER_NAME_LEN ODBC_MAX_STR_LEN
#define ODBC_GET_INFO_MAX_LEN ODBC_MAX_STR_LEN
#define ODBC_GET_CONNECT_ATTR_MAX_LEN ODBC_MAX_STR_LEN
#define ODBC_GET_STMT_ATTR_MAX_LEN ODBC_MAX_STR_LEN
#define ODBC_GET_DATA_MAX_STR_LEN ODBC_MAX_STR_LEN
#define ODBC_DESCRIBE_COL_MAX_STR_LEN ODBC_MAX_STR_LEN
#define ODBC_MAX_CURSOR_NAME_STR_LEN ODBC_MAX_STR_LEN
#define ODBC_MAX_NATIVE_SQL_STR_LEN ODBC_MAX_STR_LEN
#define ODBC_MAX_GET_DESC_FIELD_STR_LEN ODBC_MAX_STR_LEN
#define ODBC_RETVAL_BUFFER_INITIAL_SIZE 3
/* turn debug messages on/off. */ /* turn debug messages on/off. */
#define ODBC_DEBUG_MSGS 1 #define ODBC_DEBUG_MSGS 1
#define ODBC_RAISE_EXCEPTION(MSG) s48_raise_string_os_error(MSG)
#ifdef ODBC_DEBUG_MSGS #ifdef ODBC_DEBUG_MSGS
#define ODBC_DEBUG_DIAGREC(ht, h) odbc_debug_msgs(ht, h); #define ODBC_DEBUG_DIAGREC(ht, h) odbc_debug_msgs(ht, h);
#else #else
@ -52,10 +36,43 @@
#define ODBC_DEBUG_PRINTF_5(str, arg1, arg2, arg3, arg4) ; #define ODBC_DEBUG_PRINTF_5(str, arg1, arg2, arg3, arg4) ;
#endif #endif
/* offsets for scheme records */ /* import conditions */
static s48_value raise_odbc_api_version_mismatch_error = S48_FALSE;
/* some useful macros */ #define RAISE_API_VERSION_MISMATCH(FUNNAME, APIVER, APIVERNEEDED) \
#define ODBC_SUCCESS(retval) ((retval == SQL_SUCCESS) || (retval == SQL_SUCCESS_WITH_INFO)) s48_call_scheme(S48_SHARED_BINDING_REF(raise_odbc_api_version_mismatch_error), \
3, s48_enter_string(FUNNAME), \
s48_enter_integer(APIVER), s48_enter_integer(APIVERNEEDED));
static s48_value raise_odbc_unknown_integer_type_error = S48_FALSE;
#define RAISE_UNKNOWN_INTEGER_TYPE_ERROR(FUNNAME, TYPEID) \
s48_call_scheme(S48_SHARED_BINDING_REF(raise_odbc_unknown_integer_type_error), \
2, s48_enter_string(FUNNAME), s48_enter_integer(TYPEID));
static s48_value raise_odbc_buffer_alloc_error = S48_FALSE;
#define RAISE_ODBC_BUFFER_ALLOC_ERROR(BUFFERLEN) \
s48_call_scheme(S48_SHARED_BINDING_REF(raise_odbc_buffer_alloc_error), \
1, s48_enter_integer(BUFFERLEN));
static s48_value raise_odbc_unknown_c_type_identifier_error = S48_FALSE;
#define RAISE_ODBC_UNKNOWN_C_TYPE_IDENTIFIER_ERROR(BUFFER, TYPEID) \
s48_call_scheme(S48_SHARED_BINDING_REF(raise_odbc_unknown_c_type_identifier_error), \
2, s48_enter_integer(BUFFER), s48_enter_integer(TYPEID));
static s48_value raise_odbc_bindcol_unbound_column_error = S48_FALSE;
#define RAISE_ODBC_BINDCOL_UNBOUND_COLUMN_ERROR(STMTHANDLE, COLUMNNO) \
s48_call_scheme(S48_SHARED_BINDING_REF(raise_odbc_bindcol_unbound_column_error), \
2, s48_enter_integer(STMTHANDLE), s48_enter_integer(COLUMNNO));
static s48_value raise_odbc_bindcol_rebinding_error = S48_FALSE;
#define RAISE_ODBC_BINDCOL_REBINDING_ERROR(TEXTMSG) \
s48_call_scheme(S48_SHARED_BINDING_REF(raise_odbc_bindcol_rebinding_error), \
1, s48_enter_string(TEXTMSG));
/* corresponds to sql-date */ /* corresponds to sql-date */
static s48_value sql_date_record_type = S48_FALSE; static s48_value sql_date_record_type = S48_FALSE;
@ -121,9 +138,6 @@ static s48_value bindcol_buffer_record_type = S48_FALSE;
#define SR_BINDCOL_BUFFER_LENGTH 1 #define SR_BINDCOL_BUFFER_LENGTH 1
#define SR_BINDCOL_BUFFER_TARGET_TYPE 2 #define SR_BINDCOL_BUFFER_TARGET_TYPE 2
static s48_value signal_unbound_column = S48_FALSE;
static s48_value signal_buffer_exceeded = S48_FALSE;
typedef struct bindcol_col_rec *ColumnRecPtr; typedef struct bindcol_col_rec *ColumnRecPtr;
typedef struct bindcol_col_rec { typedef struct bindcol_col_rec {
@ -171,7 +185,7 @@ s48_value odbc_alloc_environment_handle();
/* given a valid environment handle (type SQLHENV) this function /* given a valid environment handle (type SQLHENV) this function
* sets the environment attributes. This needs to be done before * sets the environment attributes. This needs to be done before
* allocating a connection handle */ * allocating a connection handle */
void odbc_sql_set_env_attr(SQLHENV env_handle); s48_value odbc_sql_set_env_attr(SQLHENV env_handle);
/* Given a valid environment handle get a connection handle */ /* Given a valid environment handle get a connection handle */
s48_value odbc_alloc_connection_handle(s48_value env_handle); s48_value odbc_alloc_connection_handle(s48_value env_handle);
@ -286,12 +300,9 @@ s48_value odbc_sql_get_desc_field_string(s48_value desc_handle, s48_value rec_nu
/* Prepare a SQL statement for execution */ /* Prepare a SQL statement for execution */
s48_value odbc_sql_prepare(s48_value stmt_handle, s48_value stmt_txt); 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 odbc_sql_get_cursor_name(s48_value stmt_handle); s48_value odbc_sql_get_cursor_name(s48_value stmt_handle);
void odbc_sql_set_cursor_name(s48_value stmt_handle, s48_value cursorname); s48_value odbc_sql_set_cursor_name(s48_value stmt_handle, s48_value cursorname);
/* /*
* *
@ -324,8 +335,8 @@ s48_value odbc_sql_num_params(s48_value stmt_handle);
s48_value odbc_sql_row_count(s48_value stmt_handle); s48_value odbc_sql_row_count(s48_value stmt_handle);
s48_value odbc_sql_get_data(s48_value stmt_handle, s48_value column_number, s48_value odbc_sql_get_data(s48_value stmt_handle, s48_value column_number,
s48_value target_type, s48_value buffer_size); s48_value target_type);
/* Positions a cursor within a fetched block of data and allows an application /* 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 to refresh data in the rowset or to update or delete data in the result
@ -486,6 +497,16 @@ s48_value struct_to_sql_time_record(SQL_TIME_STRUCT *ts);
void sql_timestamp_record_to_struct(s48_value sql_timestamp, void sql_timestamp_record_to_struct(s48_value sql_timestamp,
SQL_TIMESTAMP_STRUCT *ts); SQL_TIMESTAMP_STRUCT *ts);
/* initial return value buffer size */
#define ODBC_RETVAL_BUFFER_DEFAULT_SIZE 255
static SQLUSMALLINT odbc_initial_retval_buffer_size = ODBC_RETVAL_BUFFER_DEFAULT_SIZE;
/* set initial return value buffer size */
s48_value odbc_set_initial_retval_buffer_size(s48_value nobytes);
/* get initial return value buffer size */
s48_value odbc_get_intial_retval_buffer_size();
void odbc_sql_alloc(void **buffer, size_t buffer_len, size_t type_len); void odbc_sql_alloc(void **buffer, size_t buffer_len, size_t type_len);
size_t sizeof_sql_c_type_identifier(SQLSMALLINT ctypeid); size_t sizeof_sql_c_type_identifier(SQLSMALLINT ctypeid);

View File

@ -63,6 +63,94 @@
(else (else
(error "Unknown handle type: " record)))) (error "Unknown handle type: " record))))
;;; conditions
(define-condition-type 'odbc-error '(error))
(define odbc-error?
(condition-predicate 'odbc-error))
(define-condition-type 'odbc-api-version-mismatch '(odbc-error))
(define odbc-api-version-mismatch?
(condition-predicate 'odbc-api-version-mismatch))
(define (raise-odbc-api-version-mismatch-error function-name
api-version
api-version-needed)
(apply signal 'odbc-api-version-mismatch
'function-name function-name
'odbc-driver-manager-api-version api-version
'min-api-version-required api-version-needed))
(define-exported-binding
"raise-odbc-api-version-mismatch-error"
raise-odbc-api-version-mismatch-error)
;;;
(define-condition-type 'odbc-unknown-integer-type '(odbc-error))
(define odbc-unknown-integer-type?
(condition-predicate 'odbc-unknown-integer-type))
(define (raise-odbc-unknown-integer-type-error function-name type-id)
(apply signal 'odbc-unknown-integer-type
'function-name function-name 'type-id type-id))
(define-exported-binding
"raise-odbc-unknown-integer-type-error" raise-odbc-unknown-integer-type-error)
;;;
(define-condition-type 'odbc-buffer-alloc-error '(odbc-error))
(define odbc-buffer-alloc-error?
(condition-predicate 'odbc-buffer-alloc-error))
(define (raise-odbc-buffer-alloc-error buffer-length)
(apply signal 'odbc-buffer-alloc-error 'buffer-length buffer-length))
(define-exported-binding
"raise-odbc-buffer-alloc-error" raise-odbc-buffer-alloc-error)
;;;
(define-condition-type 'odbc-unknown-c-type-identifier-error '(odbc-error))
(define odbc-unknown-c-type-identifier-error?
(condition-predicate 'odbc-unknown-c-type-identifier-error))
(define (raise-odbc-unknown-c-type-identifier-error buffer ctypeid)
(apply signal 'odbc-unknown-c-type-identifier-error
'buffer buffer 'ctypeid ctypeid))
(define-exported-binding
"raise-odbc-unknown-c-type-identifier-error"
raise-odbc-unknown-c-type-identifier-error)
;;;
(define-condition-type 'odbc-bindcol-unbound-column '(odbc-error))
(define odbc-bindcol-unbound-column-error?
(condition-predicate 'odbc-bindcol-unbound-column))
(define (raise-odbc-bindcol-unbound-column-error stmt-handle column-no)
(apply signal 'odbc-bindcol-unbound-column
'statement-handle stmt-handle 'column-no column-no))
(define-exported-binding "raise-odbc-bindcol-unbound-column-error"
raise-odbc-bindcol-unbound-column-error)
;;;
(define-condition-type 'odbc-bindcol-rebinding-error '(odbc-error))
(define odbc-bindcol-rebinding-error?
(condition-predicate 'odbc-bindcol-rebinding-error))
(define (raise-odbc-bindcol-rebinding-error text-msg)
(apply signal 'odbc-bindcol-rebinding-error text-msg))
(define-exported-binding "raise-odbc-bindcol-rebinding-error"
raise-odbc-bindcol-rebinding-error)
;;;
(define-record-type odbc-column :odbc-column (define-record-type odbc-column :odbc-column
(really-make-odbc-column name type size digits nullable?) (really-make-odbc-column name type size digits nullable?)
odbc-column? odbc-column?
@ -456,34 +544,32 @@
(define sql-invalid-handle -2) (define sql-invalid-handle -2)
(define sql-need-data 99) (define sql-need-data 99)
(define-record-type odbc-column :odbc-column
(really-make-odbc-column name type size digits nullable)
odbc-column?
(name odbc-column-name)
(type odbc-column-type)
(size odbc-column-size)
(digits odbc-column-digits)
(nullable odbc-column-nullable))
;;; PART 1 ;;; PART 1
(define (odbc-alloc-environment-handle) (define (odbc-alloc-environment-handle)
(let ((env-handle (really-make-environment-handle (let* ((status.value (odbc-alloc-environment-handle-internal))
(odbc-alloc-environment-handle-internal)))) (status (car status.value))
(add-finalizer! env-handle odbc-sql-free-handle) (value (cadr status.value)))
env-handle)) (if (odbc-call-successful? status)
(let ((env-handle (really-make-environment-handle value)))
(add-finalizer! env-handle odbc-sql-free-handle)
(values status env-handle))
(values status value))))
(import-lambda-definition odbc-alloc-environment-handle-internal (import-lambda-definition odbc-alloc-environment-handle-internal
() ()
"odbc_alloc_environment_handle") "odbc_alloc_environment_handle")
(define (odbc-alloc-connection-handle env-handle) (define (odbc-alloc-connection-handle env-handle)
(check-arg environment-handle? env-handle odbc-alloc-connection-handle) (let* ((status.value (odbc-alloc-connection-handle-internal
(let ((conn-handle (really-make-connection-handle (environment-handle-handle env-handle)))
(odbc-alloc-connection-handle-internal (status (car status.value))
(environment-handle-handle env-handle)) env-handle #f))) (value (cadr status.value)))
(add-finalizer! conn-handle free-connection-handle) (if (odbc-call-successful? status)
conn-handle)) (let ((conn-handle (really-make-environment-handle value)))
(add-finalizer! conn-handle free-connection-handle)
(values status conn-handle))
(values status value))))
(import-lambda-definition odbc-alloc-connection-handle-internal (import-lambda-definition odbc-alloc-connection-handle-internal
(env-handle) (env-handle)
@ -496,19 +582,20 @@
(odbc-sql-free-handle conn-handle)) (odbc-sql-free-handle conn-handle))
(define (odbc-alloc-statement-handle conn-handle) (define (odbc-alloc-statement-handle conn-handle)
(check-arg connection-handle? conn-handle odbc-alloc-statement-handle) (let* ((status.value (odbc-alloc-statement-handle-internal
(let ((stmt-handle (really-make-statement-handle (connection-handle-handle conn-handle)))
(odbc-alloc-statement-handle-internal (status (car status.value))
(connection-handle-handle conn-handle)) (value (cadr status.value)))
conn-handle))) (if (odbc-call-successful? status)
(add-finalizer! stmt-handle free-statement-handle) (let ((stmt-handle (really-make-statement-handle value)))
stmt-handle)) (add-finalizer! stmt-handle free-statement-handle)
(values status stmt-handle))
(values status value))))
(define (free-statement-handle stmt-handle) (define (free-statement-handle stmt-handle)
(bindcol-finalize-bindcols (statement-handle-handle stmt-handle)) (bindcol-finalize-bindcols (statement-handle-handle stmt-handle))
(odbc-sql-free-handle stmt-handle)) (odbc-sql-free-handle stmt-handle))
(import-lambda-definition odbc-alloc-statement-handle-internal (import-lambda-definition odbc-alloc-statement-handle-internal
(db-handle) (db-handle)
"odbc_alloc_statement_handle") "odbc_alloc_statement_handle")
@ -519,7 +606,6 @@
;;; returns odbc-return-value ;;; returns odbc-return-value
(define (odbc-sql-connect conn-handle server-name user-name auth) (define (odbc-sql-connect conn-handle server-name user-name auth)
(check-arg connection-handle? conn-handle odbc-sql-connect)
(let ((return-value (odbc-sql-connect-internal (let ((return-value (odbc-sql-connect-internal
(connection-handle-handle conn-handle) (connection-handle-handle conn-handle)
server-name user-name auth))) server-name user-name auth)))
@ -532,10 +618,10 @@
"odbc_sql_connect") "odbc_sql_connect")
(define (odbc-sql-browse-connect conn-handle connection-string) (define (odbc-sql-browse-connect conn-handle connection-string)
(check-arg connection-handle? conn-handle odbc-sql-browse-connect) (apply values
(odbc-sql-browse-connect-internal (connection-handle-handle conn-handle) (odbc-sql-browse-connect-internal
connection-string)) (connection-handle-handle conn-handle) connection-string)))
(import-lambda-definition odbc-sql-browse-connect-internal (import-lambda-definition odbc-sql-browse-connect-internal
(conn-handle connection-string) (conn-handle connection-string)
"odbc_sql_browse_connect") "odbc_sql_browse_connect")
@ -543,48 +629,53 @@
;;; PART 2 ;;; PART 2
(define (odbc-sql-data-sources env-handle) (define (odbc-sql-data-sources env-handle)
(check-arg environment-handle? env-handle odbc-sql-data-sources) (apply values
(reverse (odbc-sql-data-sources-internal (environment-handle-handle env-handle)))) (odbc-sql-data-sources-internal
(environment-handle-handle env-handle))))
(import-lambda-definition odbc-sql-data-sources-internal (import-lambda-definition odbc-sql-data-sources-internal
(env-handle) (env-handle)
"odbc_sql_data_sources") "odbc_sql_data_sources")
(define (odbc-sql-drivers env-handle) (define (odbc-sql-drivers env-handle)
(check-arg environment-handle? env-handle odbc-sql-drivers) (apply values
(odbc-sql-drivers-internal (environment-handle-handle env-handle))) (odbc-sql-drivers-internal
(environment-handle-handle env-handle))))
(import-lambda-definition odbc-sql-drivers-internal (import-lambda-definition odbc-sql-drivers-internal
(env-handle) (env-handle)
"odbc_sql_drivers") "odbc_sql_drivers")
(define (odbc-sql-get-info-int conn-handle info-key) (define (odbc-sql-get-info-int conn-handle info-key)
(check-arg connection-handle? conn-handle odbc-sql-get-info-int) (apply values
(odbc-sql-get-info-int-internal (connection-handle-handle conn-handle) info-key)) (odbc-sql-get-info-int-internal
(connection-handle-handle conn-handle) info-key)))
(import-lambda-definition odbc-sql-get-info-int-internal (import-lambda-definition odbc-sql-get-info-int-internal
(conn-handle info-key) (conn-handle info-key)
"odbc_sql_get_info_int") "odbc_sql_get_info_int")
(define (odbc-sql-get-info-string conn-handle info-key) (define (odbc-sql-get-info-string conn-handle info-key)
(check-arg connection-handle-handle conn-handle odbc-sql-get-info-string) (apply values
(odbc-sql-get-info-string-internal (connection-handle-handle conn-handle) info-key)) (odbc-sql-get-info-string-internal
(connection-handle-handle conn-handle) info-key)))
(import-lambda-definition odbc-sql-get-info-string-internal (import-lambda-definition odbc-sql-get-info-string-internal
(conn-handle info-key) (conn-handle info-key)
"odbc_sql_get_info_string") "odbc_sql_get_info_string")
(define (odbc-sql-get-func conn-handle fun-id) (define (odbc-sql-get-func conn-handle fun-id)
(check-arg connection-handle? conn-handle odbc-sql-get-func) (apply values
(odbc-sql-get-func-exists-internal (connection-handle-handle conn-handle) fun-id)) (odbc-sql-get-func-exists-internal
(connection-handle-handle conn-handle) fun-id)))
(import-lambda-definition odbc-sql-get-func-exists-internal (import-lambda-definition odbc-sql-get-func-exists-internal
(conn-handle fun-id) (conn-handle fun-id)
"odbc_sql_get_func_exists") "odbc_sql_get_func_exists")
(define (odbc-sql-get-type-info stmt-handle data-type) (define (odbc-sql-get-type-info stmt-handle data-type)
(check-arg statement-handle? stmt-handle data-type) (odbc-sql-get-type-info-internal
(odbc-sql-get-type-info-internal (statement-handle-handle stmt-handle) data-type)) (statement-handle-handle stmt-handle) data-type))
(import-lambda-definition odbc-sql-get-type-info-internal (import-lambda-definition odbc-sql-get-type-info-internal
(stmt-handle data-type) (stmt-handle data-type)
@ -593,90 +684,85 @@
;;; PART 3 ;;; PART 3
(define (odbc-sql-set-connect-attr-int conn-handle attribute value) (define (odbc-sql-set-connect-attr-int conn-handle attribute value)
(check-arg connection-handle? conn-handle odbc-sql-set-connect-attr-int) (odbc-sql-set-connect-attr-int-internal
(odbc-sql-set-connect-attr-int-internal (connection-handle-handle conn-handle) (connection-handle-handle conn-handle) attribute value))
attribute value))
(import-lambda-definition odbc-sql-set-connect-attr-int-internal (import-lambda-definition odbc-sql-set-connect-attr-int-internal
(conn-handle attribute value) (conn-handle attribute value)
"odbc_sql_set_connect_attr_int") "odbc_sql_set_connect_attr_int")
(define (odbc-sql-set-connect-attr-string conn-handle attribute value) (define (odbc-sql-set-connect-attr-string conn-handle attribute value)
(check-arg connection-handle? conn-handle odbc-sql-set-connect-attr-string) (odbc-sql-set-connect-attr-string-internal
(odbc-sql-set-connect-attr-string-internal (connection-handle-handle conn-handle) (connection-handle-handle conn-handle) attribute value))
attribute value))
(import-lambda-definition odbc-sql-set-connect-attr-string-internal (import-lambda-definition odbc-sql-set-connect-attr-string-internal
(conn-handle attribute value) (conn-handle attribute value)
"odbc_sql_set_connect_attr_string") "odbc_sql_set_connect_attr_string")
(define (odbc-sql-get-connect-attr-string conn-handle attribute) (define (odbc-sql-get-connect-attr-string conn-handle attribute)
(check-arg connection-handle? conn-handle odbc-sql-get-connect-attr-string) (apply values
(odbc-sql-get-connect-attr-string-internal (connection-handle-handle conn-handle) (odbc-sql-get-connect-attr-string-internal
attribute)) (connection-handle-handle conn-handle) attribute)))
(import-lambda-definition odbc-sql-get-connect-attr-string-internal (import-lambda-definition odbc-sql-get-connect-attr-string-internal
(conn-handle attribute) (conn-handle attribute)
"odbc_sql_get_connect_attr_string") "odbc_sql_get_connect_attr_string")
(define (odbc-sql-get-connect-attr-int conn-handle attribute) (define (odbc-sql-get-connect-attr-int conn-handle attribute)
(check-arg connection-handle? conn-handle odbc-sql-get-connect-attr-int) (apply values
(odbc-sql-get-connect-attr-int-internal (connection-handle-handle conn-handle) (odbc-sql-get-connect-attr-int-internal
attribute)) (connection-handle-handle conn-handle) attribute)))
(import-lambda-definition odbc-sql-get-connect-attr-int-internal (import-lambda-definition odbc-sql-get-connect-attr-int-internal
(conn-handle attribute) (conn-handle attribute)
"odbc_sql_get_connect_attr_int") "odbc_sql_get_connect_attr_int")
(define (odbc-sql-set-env-attr-int env-handle attribute value) (define (odbc-sql-set-env-attr-int env-handle attribute value)
(check-arg environment-handle? env-handle odbc-sql-set-env-attr-int) (odbc-sql-set-env-attr-int-internal
(odbc-sql-set-env-attr-int-internal (environment-handle-handle env-handle) (environment-handle-handle env-handle) attribute value))
attribute value))
(import-lambda-definition odbc-sql-set-env-attr-int-internal (import-lambda-definition odbc-sql-set-env-attr-int-internal
(env-handle attribute value) (env-handle attribute value)
"odbc_sql_set_env_attr_int") "odbc_sql_set_env_attr_int")
(define (odbc-sql-get-env-attr-int env-handle attribute value) (define (odbc-sql-get-env-attr-int env-handle attribute value)
(check-arg environment-handle? env-handle odbc-sql-get-connect-attr-int) (apply values
(odbc-sql-get-env-attr-int-internal (environment-handle-handle env-handle) (odbc-sql-get-env-attr-int-internal
attribute value)) (environment-handle-handle env-handle) attribute value)))
(import-lambda-definition odbc-sql-get-env-attr-int-internal (import-lambda-definition odbc-sql-get-env-attr-int-internal
(env-handle attribute value) (env-handle attribute value)
"odbc_sql_get_env_attr_int") "odbc_sql_get_env_attr_int")
(define (odbc-sql-set-stmt-attr-int stmt-handle attribute value) (define (odbc-sql-set-stmt-attr-int stmt-handle attribute value)
(check-arg statement-handle? stmt-handle odbc-sql-set-stmt-attr-int) (odbc-sql-set-stmt-attr-int-internal
(odbc-sql-set-stmt-attr-int-internal (statement-handle-handle stmt-handle) (statement-handle-handle stmt-handle) attribute value))
attribute value))
(import-lambda-definition odbc-sql-set-stmt-attr-int-internal (import-lambda-definition odbc-sql-set-stmt-attr-int-internal
(stmt-handle attribute value) (stmt-handle attribute value)
"odbc_sql_set_stmt_attr_int") "odbc_sql_set_stmt_attr_int")
(define (odbc-sql-set-stmt-attr-string stmt-handle attribute value) (define (odbc-sql-set-stmt-attr-string stmt-handle attribute value)
(check-arg statement-handle? stmt-handle odbc-sql-set-stmt-attr-string) (odbc-sql-set-stmt-attr-string-internal
(odbc-sql-set-stmt-attr-string-internal (statement-handle-handle stmt-handle) (statement-handle-handle stmt-handle) attribute value))
attribute value))
(import-lambda-definition odbc-sql-set-stmt-attr-string-internal (import-lambda-definition odbc-sql-set-stmt-attr-string-internal
(stmt-handle attribute value) (stmt-handle attribute value)
"odbc_sql_set_stmt_attr_string") "odbc_sql_set_stmt_attr_string")
(define (odbc-sql-get-stmt-attr-int stmt-handle attribute) (define (odbc-sql-get-stmt-attr-int stmt-handle attribute)
(check-arg statement-handle? stmt-handle odbc-sql-get-stmt-attr-int) (apply values
(odbc-sql-get-stmt-attr-int-internal (statement-handle-handle stmt-handle) (odbc-sql-get-stmt-attr-int-internal
attribute)) (statement-handle-handle stmt-handle) attribute)))
(import-lambda-definition odbc-sql-get-stmt-attr-int-internal (import-lambda-definition odbc-sql-get-stmt-attr-int-internal
(stmt-handle attribute) (stmt-handle attribute)
"odbc_sql_get_stmt_attr_int") "odbc_sql_get_stmt_attr_int")
(define (odbc-sql-get-stmt-attr-string stmt-handle attribute) (define (odbc-sql-get-stmt-attr-string stmt-handle attribute)
(check-arg statement-handle? stmt-handle odbc-sql-get-stmt-attr-string) (apply values
(odbc-sql-get-stmt-attr-string-internal (statement-handle-handle stmt-handle) (odbc-sql-get-stmt-attr-string-internal
attribute)) (statement-handle-handle stmt-handle) attribute)))
(import-lambda-definition odbc-sql-get-stmt-attr-string-internal (import-lambda-definition odbc-sql-get-stmt-attr-string-internal
(stmt-handle attribute) (stmt-handle attribute)
@ -685,18 +771,18 @@
;;; PART 4 ;;; PART 4
(define (odbc-sql-get-desc-field-int desc-handle record-number field-id) (define (odbc-sql-get-desc-field-int desc-handle record-number field-id)
(check-arg descriptor-handle? desc-handle odbc-sql-get-desc-field-int) (apply values
(odbc-sql-get-desc-field-int-internal (descriptor-handle-handle desc-handle) (odbc-sql-get-desc-field-int-internal
record-number field-id)) (descriptor-handle-handle desc-handle) record-number field-id)))
(import-lambda-definition odbc-sql-get-desc-field-int-internal (import-lambda-definition odbc-sql-get-desc-field-int-internal
(desc-handle record-number field-id) (desc-handle record-number field-id)
"odbc_sql_get_desc_field_int") "odbc_sql_get_desc_field_int")
(define (odbc-sql-get-desc-field-string desc-handle record-number field-id) (define (odbc-sql-get-desc-field-string desc-handle record-number field-id)
(check-arg descriptor-handle? desc-handle odbc-sql-get-desc-field-string) (apply values
(odbc-sql-get-desc-field-string-internal (descriptor-handle-handle desc-handle) (odbc-sql-get-desc-field-string-internal
record-number field-id)) (descriptor-handle-handle desc-handle) record-number field-id)))
(import-lambda-definition odbc-sql-get-desc-field-string-internal (import-lambda-definition odbc-sql-get-desc-field-string-internal
(desc-handle record-number field-id) (desc-handle record-number field-id)
@ -705,34 +791,25 @@
;;; PART 5 ;;; PART 5
(define (odbc-sql-prepare stmt-handle stmt-txt) (define (odbc-sql-prepare stmt-handle stmt-txt)
(check-arg statement-handle? stmt-handle odbc-sql-prepare) (odbc-sql-prepare-internal
(odbc-sql-prepare-internal (statement-handle-handle stmt-handle) (statement-handle-handle stmt-handle) stmt-txt))
stmt-txt))
(import-lambda-definition odbc-sql-prepare-internal (import-lambda-definition odbc-sql-prepare-internal
(stmt-handle stmt-txt) (stmt-handle stmt-txt)
"odbc_sql_prepare") "odbc_sql_prepare")
(define (odbc-sql-bind-parameter-exec-out stmt-handle param-vals)
(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))
(import-lambda-definition odbc-sql-bind-parameter-exec-out-internal
(stmt-handle param-vals)
"odbc_sql_bind_parameter_exec_out")
(define (odbc-sql-get-cursor-name stmt-handle) (define (odbc-sql-get-cursor-name stmt-handle)
(check-arg statement-handle? stmt-handle odbc-sql-get-cursor-name) (apply values
(odbc-sql-get-cursor-name-internal (statement-handle-handle stmt-handle))) (odbc-sql-get-cursor-name-internal
(statement-handle-handle stmt-handle))))
(import-lambda-definition odbc-sql-get-cursor-name-internal (import-lambda-definition odbc-sql-get-cursor-name-internal
(stmt-handle) (stmt-handle)
"odbc_sql_get_cursor_name") "odbc_sql_get_cursor_name")
(define (odbc-sql-set-cursor-name stmt-handle 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
(odbc-sql-set-cursor-name-internal (statement-handle-handle stmt-handle) cursor-name)) (statement-handle-handle stmt-handle) cursor-name))
(import-lambda-definition odbc-sql-set-cursor-name-internal (import-lambda-definition odbc-sql-set-cursor-name-internal
(stmt-handle cursor-name) (stmt-handle cursor-name)
@ -741,7 +818,6 @@
;;; PART 6 ;;; PART 6
(define (odbc-sql-execute stmt-handle) (define (odbc-sql-execute stmt-handle)
(check-arg statement-handle? stmt-handle odbc-sql-execute)
(odbc-sql-execute-internal (statement-handle-handle stmt-handle))) (odbc-sql-execute-internal (statement-handle-handle stmt-handle)))
(import-lambda-definition odbc-sql-execute-internal (import-lambda-definition odbc-sql-execute-internal
@ -749,35 +825,35 @@
"odbc_sql_execute") "odbc_sql_execute")
(define (odbc-sql-execute-direct stmt-handle stmt-txt) (define (odbc-sql-execute-direct stmt-handle stmt-txt)
(check-arg statement-handle? stmt-handle odbc-sql-execute-direct) (odbc-sql-execute-direct-internal
(odbc-sql-execute-direct-internal (statement-handle-handle stmt-handle) (statement-handle-handle stmt-handle) stmt-txt))
stmt-txt))
(import-lambda-definition odbc-sql-execute-direct-internal (import-lambda-definition odbc-sql-execute-direct-internal
(stmt-handle stmt-txt) (stmt-handle stmt-txt)
"odbc_sql_execute_direct") "odbc_sql_execute_direct")
(define (odbc-sql-native-sql conn-handle stmt-txt) (define (odbc-sql-native-sql conn-handle stmt-txt)
(check-arg connection-handle? conn-handle odbc-sql-native-sql) (apply values
(odbc-sql-native-sql-internal (connection-handle-handle conn-handle) (odbc-sql-native-sql-internal
stmt-txt)) (connection-handle-handle conn-handle) stmt-txt)))
(import-lambda-definition odbc-sql-native-sql-internal (import-lambda-definition odbc-sql-native-sql-internal
(conn-handle stmt-txt) (conn-handle stmt-txt)
"odbc_sql_native_sql") "odbc_sql_native_sql")
(define (odbc-sql-describe-param stmt-handle parameter-no) (define (odbc-sql-describe-param stmt-handle parameter-no)
(check-arg statement-handle? stmt-handle odbc-sql-describe-param) (apply values
(odbc-sql-describe-param-internal (statement-handle-handle stmt-handle) (odbc-sql-describe-param-internal
parameter-no)) (statement-handle-handle stmt-handle) parameter-no)))
(import-lambda-definition odbc-sql-describe-param-internal (import-lambda-definition odbc-sql-describe-param-internal
(stmt-handle parameter-no) (stmt-handle parameter-no)
"odbc_sql_describe_param") "odbc_sql_describe_param")
(define (odbc-sql-num-params stmt-handle) (define (odbc-sql-num-params stmt-handle)
(check-arg statement-handle? stmt-handle odbc-sql-num-params) (apply values
(odbc-sql-num-params-internal (statement-handle-handle stmt-handle))) (odbc-sql-num-params-internal
(statement-handle-handle stmt-handle))))
(import-lambda-definition odbc-sql-num-params-internal (import-lambda-definition odbc-sql-num-params-internal
(stmt-handle) (stmt-handle)
@ -786,51 +862,49 @@
;;; PART 7 ;;; PART 7
(define (odbc-sql-row-count stmt-handle) (define (odbc-sql-row-count stmt-handle)
(check-arg statement-handle? stmt-handle odbc-sql-row-count) (apply values
(odbc-sql-row-count-internal (statement-handle-handle stmt-handle))) (odbc-sql-row-count-internal
(statement-handle-handle stmt-handle))))
(import-lambda-definition odbc-sql-row-count-internal (import-lambda-definition odbc-sql-row-count-internal
(stmt-handle) (stmt-handle)
"odbc_sql_row_count") "odbc_sql_row_count")
(define (odbc-sql-get-data stmt-handle column-number target-type buffer-size) (define (odbc-sql-get-data stmt-handle column-number target-type)
(check-arg statement-handle? stmt-handle odbc-sql-get-data)
(odbc-sql-get-data-internal (statement-handle-handle stmt-handle) (odbc-sql-get-data-internal (statement-handle-handle stmt-handle)
column-number target-type)) column-number target-type))
(import-lambda-definition odbc-sql-get-data-internal (import-lambda-definition odbc-sql-get-data-internal
(stmt-handle column-number target-type buffer-size) (stmt-handle column-number target-type)
"odbc_sql_get_data") "odbc_sql_get_data")
(define (odbc-sql-set-pos stmt-handle row-number operation lock-type) (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
(odbc-sql-set-pos-internal (statement-handle-handle stmt-handle) (statement-handle-handle stmt-handle) row-number operation lock-type))
row-number operation lock-type))
(import-lambda-definition odbc-sql-set-pos-internal (import-lambda-definition odbc-sql-set-pos-internal
(stmt-handle row-number operation lock-type) (stmt-handle row-number operation lock-type)
"odbc_sql_set_pos") "odbc_sql_set_pos")
(define (odbc-sql-bulk-operations stmt-handle operation) (define (odbc-sql-bulk-operations stmt-handle operation)
(check-arg statement-handle? stmt-handle odbc-sql-bulk-operations) (odbc-sql-bulk-operations-internal
(odbc-sql-bulk-operations-internal (statement-handle-handle stmt-handle) (statement-handle-handle stmt-handle) operation))
operation))
(import-lambda-definition odbc-sql-bulk-operations-internal (import-lambda-definition odbc-sql-bulk-operations-internal
(stmt-handle operation) (stmt-handle operation)
"odbc_sql_bulk_operations") "odbc_sql_bulk_operations")
(define (odbc-sql-more-results stmt-handle) (define (odbc-sql-more-results stmt-handle)
(check-arg statement-handle? stmt-handle odbc-sql-more-results) (odbc-sql-more-results-internal
(odbc-sql-more-results-internal (statement-handle-handle stmt-handle))) (statement-handle-handle stmt-handle)))
(import-lambda-definition odbc-sql-more-results-internal (import-lambda-definition odbc-sql-more-results-internal
(stmt-handle) (stmt-handle)
"odbc_sql_more_results") "odbc_sql_more_results")
(define (odbc-sql-fetch stmt-handle) (define (odbc-sql-fetch stmt-handle)
(check-arg statement-handle-handle stmt-handle odbc-sql-fetch) (odbc-sql-fetch-internal
(odbc-sql-fetch-internal (statement-handle-handle stmt-handle))) (statement-handle-handle stmt-handle)))
(import-lambda-definition odbc-sql-fetch-internal (import-lambda-definition odbc-sql-fetch-internal
(stmt-handle) (stmt-handle)
@ -942,7 +1016,7 @@
(stmt-handle catalog-name schema-name table-type table-type) (stmt-handle catalog-name schema-name table-type table-type)
"odbc_sql_tables") "odbc_sql_tables")
;;; part 9 ;;; PART 9
(define (odbc-sql-free-statement stmt-handle option) (define (odbc-sql-free-statement stmt-handle option)
(check-arg statement-handle? stmt-handle odbc-sql-free-statement) (check-arg statement-handle? stmt-handle odbc-sql-free-statement)
@ -1029,6 +1103,14 @@
(handle-type handle) (handle-type handle)
"odbc_sql_get_diag_recs") "odbc_sql_get_diag_recs")
(import-lambda-definition odbc-set-initial-retval-buffer-size
(no-bytes)
"odbc_set_initial_retval_buffer_size")
(import-lambda-definition odbc-get-initial-retval-buffer-size
()
"odbc_get_intial_retval_buffer_size")
;;; misc stuff ;;; misc stuff
(define (odbc-call-successful? odbc-return-value) (define (odbc-call-successful? odbc-return-value)
(or (equal? odbc-return-value sql-success) (or (equal? odbc-return-value sql-success)

View File

@ -26,8 +26,8 @@ their own drivers.
The \textit{Data Source Name}, DSN for short, associates credentials The \textit{Data Source Name}, DSN for short, associates credentials
needed to logon a certain database with a the apropriate driver to needed to logon a certain database with a the apropriate driver to
access that database. If an application wishes to connect to a DSN access that database. If an application wishes to connect to a DSN
the driver manager loads the ##angegeben## driver and routes all the driver manager loads the specified driver and routes all functions
functions call by the application via this driver to the database. call by the application via this driver to the database.
The are at least two implementation of ODBC driver managers for UNIX The are at least two implementation of ODBC driver managers for UNIX
systems: unixODBC~\cite{BlaBla} and iODBC~\cite{BlaBla}. The Scheme systems: unixODBC~\cite{BlaBla} and iODBC~\cite{BlaBla}. The Scheme
@ -37,8 +37,8 @@ during compilation of scsh which one to use.
Support for ODBC at this time is quite low-level---for alsmost each Support for ODBC at this time is quite low-level---for alsmost each
function or data structure in the ODBC API there is a function call in function or data structure in the ODBC API there is a function call in
Scheme. This chapter describes how to call the API functions from Scheme. This chapter describes how to call the API functions from
Scheme, but does not cover the ##funktionsweise## of the underlying Scheme, but does not cover the functionality of the underlying ODBC
ODBC function call in detail. Microsoft's ODBC API reference function call in detail. Microsoft's ODBC API reference
manual~\cite{BlaBla} explains all API functions in great detail. manual~\cite{BlaBla} explains all API functions in great detail.
\section{ODBC Data Types} \section{ODBC Data Types}