You can programmatically retrieve result set or database structure descriptions. These descriptions are known as schema information, and this information is available through the UltraLite C API schema classes.
You cannot modify the schema using the UltraLite C API. You can only retrieve the schema information.
You can access the following schema objects and information:
ULResultSetSchema Describes a query or data in a table. It exposes the identifier, name, and type information of each column, and the number of columns in the table. ULResultSetSchema classes can be retrieved from the following classes:
ULDatabaseSchema Exposes the number and names of the tables and publications in the database, and the global properties such as the format of dates and times. ULDatabaseSchema classes can be retrieved from ULConnection classes.
ULTableSchema Exposes information about the column and index configurations. The column information in the ULTableSchema class complements the information available from the ULResultSetSchema class. For example, you can determine whether columns have default values or permit null values. ULTableSchema classes can be retrieved from ULTable classes.
The ULResultSetSchema class is returned as a constant reference unlike the ULDatabaseSchema, ULTableSchema and ULIndexSchema classes, which are returned as pointers. You cannot close a class that returns a constant reference but you must close classes that are returned as pointers.
The following code demonstrates proper and improper use of schema class closure:
// This code demonstrates proper use of the ULResultSetSchema class: const ULResultSetSchema & rss = prepStmt->GetResultSetSchema(); ccount = prepStmt->GetSchema().GetColumnCount(); // This code demonstrates proper use of the ULDatabaseSchema class: ULDatabaseSchema * dbs = conn->GetResultSetSchema(); tcount = dbs->GetTableCount(); dbs->Close(); // This line is required. // This code demonstrates improper use of the ULDatabaseSchema class // because the object needs to be closed using the Close method: tcount = conn->GetResultSetSchema()->GetTableCount();
Discuss this page in DocCommentXchange.
|Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0|