X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-odbc%2Fodbc-sql.lisp;h=227c217c4392810866a447451eac104065e913ed;hb=8c6c643e3debe875bd14408cc3129d8148dfd125;hp=2769bf91b3c6b6881b6bf4bc77d16feb6b8b68fd;hpb=9bbed78051e80e6ab76ae47834136035602bbbf1;p=clsql.git diff --git a/db-odbc/odbc-sql.lisp b/db-odbc/odbc-sql.lisp index 2769bf9..227c217 100644 --- a/db-odbc/odbc-sql.lisp +++ b/db-odbc/odbc-sql.lisp @@ -17,7 +17,7 @@ ;;;; ************************************************************************* (defpackage #:clsql-odbc - (:use #:common-lisp #:clsql-base) + (:use #:common-lisp #:clsql-sys) (:export #:odbc-database) (:documentation "This is the CLSQL interface to ODBC.")) @@ -50,15 +50,14 @@ :data-source-name dsn)))) (store-type-of-connected-database db) db) - (clsql-error (e) - (error e)) - #+ignore - (error () ;; Init or Connect failed - (error 'clsql-connect-error - :database-type database-type - :connection-spec connection-spec - :errno nil - :error "Connection failed"))))) + #+ignore + (sql-condition (e) + (error e)) + (error () ;; Init or Connect failed + (error 'sql-connection-error + :database-type database-type + :connection-spec connection-spec + :message "Connection failed"))))) (defmethod database-underlying-type ((database odbc-database)) (database-odbc-db-type database)) @@ -92,29 +91,27 @@ (odbc-dbi:sql query-expression :db (database-odbc-conn database) :result-types result-types :column-names field-names) - (clsql-error (e) - (error e)) #+ignore + (sql-error (e) + (error e)) (error () - (error 'clsql-sql-error + (error 'sql-database-data-error :database database :expression query-expression - :errno nil - :error "Query failed")))) + :message "Query failed")))) (defmethod database-execute-command (sql-expression (database odbc-database)) (handler-case (odbc-dbi:sql sql-expression :db (database-odbc-conn database)) - (clsql-error (e) - (error e)) #+ignore + (sql-error (e) + (error e)) (error () - (error 'clsql-sql-error + (error 'sql-database-data-error :database database :expression sql-expression - :errno nil - :error "Execute command failed")))) + :message "Execute command failed")))) (defstruct odbc-result-set (query nil) @@ -138,13 +135,11 @@ (length column-names) nil ;; not able to return number of rows with odbc )) - #+ignore (error () - (error 'clsql-sql-error + (error 'sql-database-data-error :database database :expression query-expression - :errno nil - :error "Query result set failed")))) + :message "Query result set failed")))) (defmethod database-dump-result-set (result-set (database odbc-database)) (odbc-dbi:close-query (odbc-result-set-query result-set)) @@ -256,10 +251,14 @@ ;; NULLABLE is the eleventh column (loop for row in rows when (string-equal attribute (fourth row)) - do (return (values (ensure-keyword (sixth row)) - (parse-integer (seventh row) :junk-allowed t) - (parse-integer (ninth row) :junk-allowed t) - (parse-integer (nth 10 row) :junk-allowed t)))))) + do + (let ((size (seventh row)) + (precision (ninth row)) + (scale (nth 10 row))) + (return (values (ensure-keyword (sixth row)) + (when size (parse-integer size)) + (when precision (parse-integer precision)) + (when scale (parse-integer scale)))))))) (defmethod database-set-sequence-position (sequence-name (position integer) @@ -355,5 +354,5 @@ ;; nothing to do t) -(when (clsql-base:database-type-library-loaded :odbc) - (clsql-base:initialize-database-type :database-type :odbc)) +(when (clsql-sys:database-type-library-loaded :odbc) + (clsql-sys:initialize-database-type :database-type :odbc))