CFX_ODBCInfov2.005/PRIL/2004© Claude Schnéegans |
|---|
| DESCRIPTION |
|---|
Another characteristic is also that all functionalities returning informations about database are centralized in the same convenient tag: datasources on a server, tables inside datasources, columns inside tables.
CFX_OBDCInfo does not return any data contained in the database, but information about its structure like table names, table types, column names, types, sizes, default values, etc.
CFX_OBDCInfo works on the complete ODBC structure: the higher level inside a datasource being catalogs: catalogs contain schemas which contain database objects like tables which in turn contain columns. By supplying correct values to the tag attributes, the user may get lists and types about all these different objects levels.
Only large database systems use higher levels like catalogs or shemas. For instance an Access database has only one catalog, the database itself and no schemas.
| NOTE |
|---|
| INSTALLATION |
|---|
You do this by going to the "CFX Tags" tab in the administrator,
For more information refer to the ColdFusion documentation "Managing CFXs".
This tag uses standard Microsoft ODBC dynamic library and does not require any special piece of soft installed like DAO or other, except ODBC of course. It has been tested on Windows98 and NT.
Important Note:
This tag uses the following DLL which must be active on your system:
ADVAPI32.DLL COMCTL32.DLL COMDLG32.DLL GDI32.DLL KERNEL32.DLL MSVCRT.DLL ODBC32.DLL ODBCINFO.DLL SHELL32.DLL SHLWAPI.DLL USER32.DLL WINSPOOL.DRV
If one of these files is missing, you will probabily get the following error message message:
Error loading CFX custom tag library The library associated with the custom tag CFX_ODBCINFO (c:\coldfusion\bin\cftags\odbcinfo.dll) was not found. Please check the LibraryPath entry for this tag in the custom tag database to verify that the library file exists and is accessible by the ColdFusion service.
If you have only downloaded the demo version, any query returned by the tag will contain only the 5 first rows.
| SYNTAX & TABLE OF CONTENT |
|---|
<CFX_ODBCInfo NAME= DUMP="YES|NO" SELECT="DATASOURCES |DRIVERS |VERSIONS |CATALOGS |SCHEMAS |TABLETYPES |COLUMNTYPES |TABLES |INDEXES |COLUMNS" |PROCEDURES New!" |PRIMARYKEYS New! |FOREIGNKEYS New! DATASOURCE= CATALOG= PKCATALOG New!= FKCATALOG New!= SCHEMA= PKSCHEMA New!= FKSCHEMA New!= TABLE= PKTABLE New!= FKTABLE New!= TABLETYPE= COLUMN= UNIQUE ORDERBY= > |
Tag & attribute list
Examples |
| QUERY COLUMNS |
|---|
| Column Name | Description of Content |
|---|---|
| Name | Name of the datasource |
| Description | Name of the ODBC driver used by the datasource |
| Column Name | Description of Content |
|---|---|
| Name | Name of the driver |
| Description | Driver attribute keywords. (Don't know if some one may ever use it, but the info is there.) |
| Column Name | Description of Content |
|---|---|
| Name | Name of the datasource |
| DriverName | A character string with the filename of the driver used to access the data source. |
| DriverODBCVersion | A character string with the version of ODBC that the driver supports. The version is of the form ##.##, where the first two digits are the major version and the next two digits are the minor version. |
| DriverVersion | A character string with the version of the driver and, optionally a description of the driver. At a minimum, the version is of the form ##.##.####, where the first two digits are the major version, the next two digits are the minor version, and the last four digits are the release version. |
| ODBCVersion | A character string with the version of ODBC to which the Driver Manager conforms. The version is of the form ##.##, where the first two digits are the major version and the next two digits are the minor version. |
| DatabaseName | A character string with the name of the current database in use, if the data source defines a named object called "database." |
| DBMSName | A character string with the name of the DBMS product accessed by the driver. |
| DBMSVersion | A character string indicating the version of the DBMS product accessed by the driver. The version is of the form ##.##.####, where the first two digits are the major version, the next two digits are the minor version, and the last four digits are the release version. The driver must render the DBMS product version in this form, but can also append the DBMS product-specific version as well. For example, "04.01.0000 Rdb 4.1". |
| ServerName | A character string with the actual data source-specific server name; (ex: ACCESS, Visual FoxPro, etc). |
| Column Name | Description of Content |
|---|---|
| Catalog | Name of the catalog |
| Column Name | Description of Content |
|---|---|
| Schema | Name of the schema |
| Column Name | Description of Content |
|---|---|
| TableType | Name of the table type (ie: TABLE, SYSTEM TABLE, VIEW,...) |
| Column Name | Description of Content |
|---|---|
| Catalog | Catalog name; it returns an empty string ("") for those tables that do not have catalogs. |
| Schema | Schema name; it returns an empty string ("") for those tables that do not have schemas. |
| TableName | Table name. |
| TableType | Table type name; one of the following: “TABLE”, “VIEW”, “SYSTEM TABLE”, “GLOBAL TEMPORARY”, “LOCAL TEMPORARY”, “ALIAS”, “SYNONYM”, or a data source – specific type name. |
| TableDescription | A description of the table. |
| Column Name | Description of Content |
|---|---|
| Catalog | Catalog name; it returns an empty string ("") for those tables that do not have catalogs. |
| Schema | Schema name; it returns an empty string ("") for those tables that do not have schemas. |
| ProcName | Procedure name. |
| ProcType | Procedure type name; one of the following:
|
| Remark | A description of the procedure. |
| Column Name | Description of Content |
|---|---|
| TypeName | Data source-dependent data type name; for example, "CHAR", "VARCHAR", "MONEY", "LONG VARBINARY", or "CHAR ( ) FOR BIT DATA". Applications must use this name in CREATE TABLE and ALTER TABLE statements. |
| Precision | The maximum precision of the data type on the data source. N/A is returned for data types where precision is not applicable. For more information on precision, see Precision, Scale, Length, and Display Size. |
| LiteralPrefix* | Character or characters used to prefix a literal; for example, a single quote ( ' ) for character data types or 0x for binary data types; An empty string is returned for data types where a literal prefix is not applicable. |
| LiteralSuffix* | Character or characters used to terminate a literal; for example, a single quote ( ' ) for character data types; NULL is returned for data types where a literal suffix is not applicable. |
| Nullable* | “NO” if the column does not include NULLs.
“YES” if the column could include NULLs.
This column returns an empty string if nullability is unknown. |
| CaseSensitive | Whether a character data type is case sensitive in collations and comparisons:
"YES" if the data type is a character data type and is case sensitive. "NO" if the data type is not a character data type or is not case sensitive. |
| Searchable* | How the data type is used in a WHERE clause. May be one of the following strings:
UNSEARCHABLE if the data type cannot be used in a WHERE clause. LIKE_ONLY if the data type can be used in a WHERE clause only with the LIKE predicate. ALL_EXCEPT_LIKE if the data type can be used in a WHERE clause with all comparison operators except LIKE. SEARCHABLE if the data type can be used in a WHERE clause with any comparison operator. UNKNOWN. |
| Unsigned* | Whether the data type is unsigned: "YES", "NO" or "N/A". |
| Money* | Whether the data type is a money data type: "YES", "NO" or "N/A". |
| AutoIncrement* | Whether the data type is autoincrementing: "YES", "NO" or "N/A". An application can insert values into a column having this attribute, but cannot update the values in the column.
Caution: a COUNTER type in Access is not considered as having the AUTOINCREMENT status since it cannot be inserted a value at all. |
| Column Name | Description of Content |
|---|---|
| Catalog | Catalog name; it returns an empty string ("") for those tables that do not have catalogs. |
| Shema | Schema name; it returns an empty string ("") for those tables that do not have schemas. |
| TableName/ProcName | Table or procedure name. The query uses TableName for tables or ProcName for procedures |
| ColumnName | Column name. The driver returns an empty string for a column that does not have a name. |
| Type | Data source – dependent data type name; for example, “CHAR”, “VARCHAR”, “MONEY”, “LONG VARBINAR”, or “CHAR ( ) FOR BIT DATA”. |
| Size | If DATA_TYPE is SQL_CHAR or SQL_VARCHAR, then this column contains the maximum length in characters of the column. For datetime data types, this is the total number of characters required to display the value when converted to characters. For numeric data types, this is either the total number of digits or the total number of bits allowed in the column, according to the NUM_PREC_RADIX column. For interval data types, this is the number of characters in the character representation of the interval literal (as defined by the interval leading precision). |
| BufferLength | The length in bytes of data transferred in a query operation. For numeric data, this size may be different than the size of the data stored on the data source. This value is the same as the COLUMN_SIZE column for character or binary data. |
| DecimalDigits | The total number of significant digits to the right of the decimal point, depending on the data type. For SQL_TYPE_TIME and SQL_TYPE_TIMESTAMP, this column contains the number of digits in the fractional seconds component. For the other data types, this is the decimal digits of the column on the data source. For interval data types that contain a time component, this column contains the number of digits to the right of the decimal point (fractional seconds). This column is empty for data types where decimal digits is not applicable. |
| NumPrecRadix | For numeric data types, either 10 or 2. If it is 10, the values in COLUMN_SIZE and DECIMAL_DIGITS give the number of decimal digits allowed for the column. For example, a DECIMAL(12,5) column would return a NUM_PREC_RADIX of 10, a COLUMN_SIZE of 12, and a DECIMAL_DIGITS of 5; a FLOAT column could return a NUM_PREC_RADIX of 10, a COLUMN_SIZE of 15 and a DECIMAL_DIGITS of NULL.
If it is 2, the values in COLUMN_SIZE and DECIMAL_DIGITS give the number of bits allowed in the column. For example, a FLOAT column could return a RADIX of 2, a COLUMN_SIZE of 53, and a DECIMAL_DIGITS of NULL. This column is empty for data types where NUM_PREC_RADIX is not applicable. |
| Description | A description of the column. |
| Default | The default value of the column. The value in this column should be interpreted as a string if it is enclosed in quotation marks.
If NULL was specified as the default value, then this column is the word NULL, not enclosed in quotation marks. If the default value cannot be represented without truncation, then this column contains TRUNCATED, with no enclosing single quotation marks. If no default value was specified, then this column is NULL. |
| Ordinal | The ordinal position of the column in the table. The first column in the table is number 1. |
| Nullable* | “NO” if the column does not include NULLs.
“YES” if the column could include NULLs.
This column returns an empty string if nullability is unknown. |
| LiteralPrefix* | Character or characters used to prefix a literal; for example, a single quote ( ' ) for character data types or 0x for binary data types; NULL is returned for data types where a literal prefix is not applicable. |
| LiteralSuffix* | Character or characters used to terminate a literal; for example, a single quote ( ' ) for character data types; NULL is returned for data types where a literal suffix is not applicable. |
| Params (New in version 2.0) |
A list of keywords, separated by commas, corresponding to each parameter that the application may specify in parentheses when using the name that is returned in the TYPE_NAME field. The keywords in the list can be any of the following: length, precision, or scale. They appear in the order that the syntax requires them to be used. For example, CREATE_PARAMS for DECIMAL would be "precision,scale"; CREATE_PARAMS for VARCHAR would equal "length." NULL is returned if there are no parameters for the data type definition; for example, INTEGER. The driver supplies the CREATE_PARAMS text in the language of the country/region where it is used. . |
| Searchable* | How the data type is used in a WHERE clause. May be one of the following strings:
UNSEARCHABLE if the data type cannot be used in a WHERE clause. LIKE_ONLY if the data type can be used in a WHERE clause only with the LIKE predicate. ALL_EXCEPT_LIKE if the data type can be used in a WHERE clause with all comparison operators except LIKE. SEARCHABLE if the data type can be used in a WHERE clause with any comparison operator. UNKNOWN. |
| Unsigned* | Whether the data type is unsigned: "YES", "NO" or "N/A". |
| Money* | Whether the data type is a money data type: "YES", "NO" or "N/A". |
| AutoIncrement* | Whether the data type is autoincrementing: "YES", "NO" or "N/A". An application can insert values into a column having this attribute, but cannot update the values in the column.
Caution: a COUNTER type in Access is not considered as having the AUTOINCREMENT status since it cannot be inserted a value at all. |
| ProcColumnType | This column is return only for procedures. Defines the procedure column as a parameter or a result set column. This ca take the following values:
|
| Column Name | Description of Content |
|---|---|
| IndexName | Index name. |
| ColumnName | Name of the indexed column. |
| Order (New in version 2.0) |
Sort sequence for the column: "A" for ascending; "D" for descending; An empty string is returned if column sort sequence is not supported by the data source. |
| Unique | YES if the index contains unique keys, NO othewise |
| Filter (New in version 2.0) |
If the index is a filtered index, this is the filter condition, such as SALARY > 30000; if the filter condition cannot be determined, or if there the index has no filter condition, this is an empty string. |
Depending on the type of ODBC driver, a couple of these columns may not be defined. In this case, the column will contain the string "N/A".
List of primary keys in a table (New in version 2.0)
This query is returned when the attribute DATASOURCE contains a valid datasource name and SELECT="PRIMARYKEYS".
The query has the following columns:
| Column Name | Description of Content |
|---|---|
| Catalog | Primary key table catalog name; it returns an empty string ("") for those tables that do not have catalogs. |
| Schema | Primary key table schema name; it returns an empty string ("") for those tables that do not have schemas. |
| Table | Primary key table name. |
| Column | Primary key column name. The ODBC driver returns an empty string for a column that does not have a name. |
| Name | Primary key name. EMPTY if not applicable to the data source. |
| Squence | Column sequence number in key (starting with 1). |
| Column Name | Description of Content |
|---|---|
| PKCatalog | Primary key table catalog name; it returns an empty string ("") for those tables that do not have catalogs. |
| PKSchema | Primary key table schema name; it returns an empty string ("") for those tables that do not have schemas. |
| PKTable | Primary key table name. |
| PKColumn | Primary key column name. The ODBC driver returns an empty string for a column that does not have a name. |
| PKName | Primary key name. EMPTY if not applicable to the data source. |
| FKCatalog | Foreign key table catalog name; it returns an empty string ("") for those tables that do not have catalogs. |
| FKSchema | Foreign key table schema name; it returns an empty string ("") for those tables that do not have schemas. |
| FKTable | Foreign key table name. |
| FKColumn | Foreign key column name. The ODBC driver returns an empty string for a column that does not have a name. |
| FKName | Foreign key name. EMPTY if not applicable to the data source. |
| Sequence | Column sequence number in key (starting with 1). |
| EXAMPLES |
|---|
All these examples use the cfexamples database which is normally installed with ColdFusion.
The folowing code is an example which may be used to specify background colors for the table generated by the tag:
<STYLE>
TABLE {background-color: FFFCF9}
TH {background-color: FFBF80}
</STYLE>
<body BGCOLOR="FFE7CC">