diff --git a/scsh/odbc/odbc.scm b/scsh/odbc/odbc.scm index 4e479d6..2c87800 100644 --- a/scsh/odbc/odbc.scm +++ b/scsh/odbc/odbc.scm @@ -27,12 +27,31 @@ (define-exported-binding "database-handle" :database-handle) +; record type to store infos from SQLGetDiagRec() +(define-record-type odbc-diag :odbc-diag + (really-make-odbc-diag-rec sql-state native-error message) + odbc-diag? + (sql-state odbc-diag-sql-state) + (native-error odbc-diag-native-error) + (message odbc-diag-message)) + +(define-exported-binding "odbc-diag" :odbc-diag) + (define (odbc-handle? thing) (or (environment-handle? thing) (connection-handle? thing) (statement-handle? thing) (database-handle? thing))) +(define (odbc-handle handle) + (cond + ((environment-handle? handle) (environment-handle-handle handle)) + ((connection-handle? handle) (connection-handle-handle handle)) + ((statement-handle? handle) (statement-handle-handle handle)) + ((database-handle? handle) (database-handle-handle handle)) + (else + (error "Expected odbc-handle, got " handle odbc-handle)))) + ;;; map a record to a handle type identifier (see sql.h) (define (handle-record-type->c-handle-identifier record) (cond ((environment-handle? record) 1) ; SQL_HANDLE_ENV @@ -633,8 +652,17 @@ (define (odbc-sql-free-handle handle) (check-arg odbc-handle? handle odbc-sql-free-handle) (odbc-sql-free-handle-internal (handle-record-type->c-handle-identifier handle) - handle)) + (odbc-handle handle))) (import-lambda-definition odbc-sql-free-handle-internal (handle-type handle) "odbc_sql_free_handle") + +(define (odbc-sql-get-diag-recs handle) + (check-arg odbc-handle? handle odbc-sql-get-diag-recs) + (odbc-sql-get-diag-recs-internal (handle-record-type->c-handle-identifier handle) + (odbc-handle handle))) + +(import-lambda-definition odbc-sql-get-diag-recs-internal + (handle-type handle) + "odbc_sql_get_diag_recs") \ No newline at end of file