scsh-0.6/scsh/odbc/odbc-bindcol.scm

55 lines
1.8 KiB
Scheme

;;; condition to signal that the buffer was too small
(define-condition-type 'odbc-buffer-exceeded '(error))
(define odbc-buffer-exceeded?
(condition-predicate 'odbc-buffer-exceeded))
(define (signal-buffer-exceeded buffer-needed buffer-contents)
(signal 'odbc-buffer-exceeded buffer-needed buffer-contents))
(define-exported-binding "signal-buffer-exceeded" signal-buffer-exceeded)
;;; tried lookup for a column that is not bound
(define-condition-type 'odbc-unbound-column '(error))
(define odbc-unbound-column?
(condition-predicate 'odbc-unbound-column))
(define (signal-unbound-column stmt-handle column-no)
(signal 'odbc-unbound-column stmt-handle column-no))
(define-exported-binding "signal-unbound-column" signal-unbound-column)
(define (odbc-sql-bindcol stmt-handle column-no target-type buffer-len)
(check-arg statement-handle? stmt-handle odbc-sql-bindcol)
(let ((handle (statement-handle-handle stmt-handle)))
(odbc-sql-bindcol-internal handle column-no target-type buffer-len)
(cond ((equal? target-type sql-type-c-char)
(lambda ()
(display "lookup char")
(newline)
(bindcol-lookup-binding-char handle column-no)))
((or (equal? target-type sql-type-c-long)
(equal? target-type sql-type-c-short))
(lambda ()
(display "lookup int")
(newline)
(bindcol-lookup-binding-int handle column-no)))
(else
(error "Can't handle that datatype yet" target-type)))))
(import-lambda-definition odbc-sql-bindcol-internal
(stmt-handle column-no target-type buffer-len)
"odbc_sql_bindcol")
(import-lambda-definition bindcol-lookup-binding-int
(stmt-handle column-no)
"bindcol_lookup_binding_int")
(import-lambda-definition bindcol-lookup-binding-char
(stmt-handle column-no)
"bindcol_lookup_binding_char")