-(defmethod database-list-tables ((database odbc-database)
- &key (owner nil))
- (declare (ignore owner))
- (multiple-value-bind (rows col-names)
- (odbc-dbi:list-all-database-tables :db (database-odbc-conn database))
- (declare (ignore col-names))
- ;; TABLE_SCHEM is hard-coded in second column by ODBC Driver Manager
- ;; TABLE_NAME in third column, TABLE_TYPE in fourth column
- (loop for row in rows
- when (and (not (string-equal "information_schema" (nth 1 row)))
- (string-equal "TABLE" (nth 3 row)))
- collect (nth 2 row))))
-
-(defmethod database-list-views ((database odbc-database)
- &key (owner nil))
- (declare (ignore owner))
- (multiple-value-bind (rows col-names)
- (odbc-dbi:list-all-database-tables :db (database-odbc-conn database))
- (declare (ignore col-names))
- ;; TABLE_SCHEM is hard-coded in second column by ODBC Driver Manager
- ;; TABLE_NAME in third column, TABLE_TYPE in fourth column
- (loop for row in rows
- when (and (not (string-equal "information_schema" (nth 1 row)))
- (string-equal "VIEW" (nth 3 row)))
- collect (nth 2 row))))
-
-(defmethod database-list-attributes ((table string) (database odbc-database)
- &key (owner nil))
- (declare (ignore owner))
- (multiple-value-bind (rows col-names)
- (odbc-dbi:list-all-table-columns table :db (database-odbc-conn database))
- (declare (ignore col-names))
- ;; COLUMN_NAME is hard-coded by odbc spec as fourth position
- (loop for row in rows
- collect (fourth row))))
-
-(defmethod database-attribute-type ((attribute string) (table string) (database odbc-database)
- &key (owner nil))
- (declare (ignore owner))
- (multiple-value-bind (rows col-names)
- (odbc-dbi:list-all-table-columns table :db (database-odbc-conn database))
- (declare (ignore col-names))
- ;; COLUMN_NAME is hard-coded by odbc spec as fourth position
- ;; TYPE_NAME is the sixth column
- ;; PRECISION/COLUMN_SIZE is the seventh column
- ;; SCALE/DECIMAL_DIGITS is the ninth column
- ;; NULLABLE is the eleventh column
- (loop for row in rows
- when (string-equal attribute (fourth row))
- 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))))))))