All Manuals > LispWorks® User Guide and Reference Manual > 45 The SQL Package

list-attribute-types Function

Summary

Returns type information for a table's attributes.

Package

sql

Signature

list-attribute-types table &key database owner => result

Arguments
table
A table.
database
A database.
owner
nil, :all or a string.
Values
result
A list.
Description

The function list-attribute-types returns type information for the attributes in the table given by table in database.

database defaults to the value of *default-database*.

If owner is nil, only user-owned attributes are considered. This is the default.

If owner is :all, all attributes are considered.

If owner is a string, this denotes a username and only attributes owned by owner are considered.

result is a list in which each element is a list (attribute datatype precision scale nullable). attribute is a string denoting the attribute name. datatype is the vendor-specific type as described in attribute-type. nullable is 1 if the attribute accepts the value NULL, and 0 otherwise.

Notes

When using ODBC to connect to Access database, the nullable value is not reliable, at least on version 7.1. There seems to be a bug in the driver. Using ODBC with other DBMS works as documented.

Examples

To print the type of every attribute in the database, do:

(loop for tab in 
      (sql:list-tables)
      do 
      (loop for type-info in 
            (sql:list-attribute-types tab)
            do
            (format t "~&Table ~S Attribute ~S Type ~S" 
                    tab
                    (first type-info)
                    (second type-info))))
See also

attribute-type
list-attributes


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:56