DB2ResultSet.GetSchemaTable Method

Returns a DataTable that describes the column metadata of the DB2ResultSet Class .

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Function GetSchemaTable() As DataTable
[C#]
public DataTable GetSchemaTable();
[C++]
public: DataTable* GetSchemaTable();
[JScript]
public function GetSchemaTable() : DataTable;

Return value

A DataTable that describes the column metadata.

Exceptions

Exception type Condition
InvalidOperationException The DB2®DataReader is closed.

Remarks

The GetSchemaTable method returns metadata about each column in the following order:

DataReader Description
AllowDBNull true if the consumer can set the column to a null value or if the driver cannot determine whether the consumer can set the column to a null value. Otherwise, false. A column may contain null values, even if it cannot be set to a null value.
BaseCatalogName The name of the catalog in the database that contains the column. NULL if the base catalog name cannot be determined. The default for this column is a null value.
BaseColumnName The name of the column in the database. This might be different than the column name returned in the ColumnName column if an alias was used. A null value if the base column name cannot be determined or if the rowset column is derived, but not identical to, a column in the database. The default for this column is a null value.
BaseSchemaName The name of the schema in the database that contains the column. NULL if the base schema name cannot be determined. The default for this column is a null value.
BaseTableName The name of the table or view in the database that contains the column. A null value if the base table name cannot be determined. The default of this column is a null value.
ColumnName The name of the column; this might not be unique. If the column name cannot be determined, a null value is returned. This name always reflects the most recent naming of the column in the current view or command text.
ColumnOrdinal The ordinal of the column. This is zero for the bookmark column of the row, if any. Other columns are numbered starting with 1. This column cannot contain a null value.
ColumnSize The maximum possible length of a value in the column. For columns that use a fixed-length data type, this is the size of the data type.
DataType Maps to the common language runtime type of Db2® Data Type.
IsAutoIncrement true if the column assigns values to new rows in fixed increments; otherwise false. The default for this column is false.
IsKey

true: The column is one of a set of columns in the rowset that, taken together, uniquely identify the row. The set of columns with IsKey set to true must uniquely identify a row in the rowset. There is no requirement that this set of columns is a minimal set of columns. This set of columns may be generated from a base table primary key, a unique constraint or a unique index.

false: The column is not required to uniquely identify the row.

IsLong true if the column contains a Binary Large Object (BLOB) that contains very long data.
IsReadOnly true if the column cannot be modified; otherwise false. If the column is set true, it retrieves key information for the result set by using CommandBehavior.KeyInfo property.
IsRowVersion Set if the column contains a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row.
IsUnique

true: No two rows in the base table, the table returned in BaseTableName, can have the same value in this column. IsUnique is guaranteed to be true if the column constitutes a key by itself or if there is a constraint of type UNIQUE that applies only to this column.1

false: The column can contain duplicate values in the base table. The default for this column is false.

NumericPrecision If Db2 Data Type is a numeric data type, this is the maximum precision of the column. The precision depends on the definition of the column. If Db2 Data Type is not a numeric data type, this is a null value.
NumericScale If Db2 Data Type is Decimal, the number of digits to the right of the decimal point. Otherwise, this is a null value.
ProviderType The Db2Type enumeration.

A row will be returned for every column in the results set.

DB2CommandBuilder needs the correct identification of the primary keys of the table in order to work properly. If the BaseTableName is not returned for every column in the query results, the IBM® Data Server Provider for .NET will try to parse the SQL statement to find the table names involved in the query. This works with UPDATE, INSERT, DELETE and simple SELECT statements, but not with stored procedures or SELECT statements based on joins. In cases where some or all of the schema information is missing from this table, the DB2CommandBuilder will not work correctly, since it does not have enough schema information to automatically generate the correct INSERT, UPDATE, or DELETE statements.

1 Tables with composite primary keys will report IsUnique as false even if a unique constraint exists on one or more of the columns.