可以通过编程方式检索结果集或数据库结构的说明。这些说明称为模式信息,此信息通过 UltraLite C API 模式类提供。
您无法使用 UltraLite C API 修改模式。只能检索模式信息。
您可以访问以下模式对象和信息:
ULResultSetSchema 描述表中的查询或数据。提供每列的标识符、名称和类型信息,以及表中的列数。ULResultSetSchema 类可以从以下类中检索:
ULDatabaseSchema 提供数据库中表和发布的数量和名称,以及日期和时间格式等全局属性。ULDatabaseSchema 类可以从 ULConnection 类中检索。
ULTableSchema 提供有关列和索引配置的信息。ULTableSchema 类中的列信息是 ULResultSetSchema 类中可用信息的补充。例如,您可以确定哪些列有缺省值或允许空值。ULTableSchema 类可以从 ULTable 类中检索。
ULIndexSchema 返回有关索引中的列的信息。ULIndexSchema 类可以从 ULTableSchema 类中检索。
ULResultSetSchema 类作为常量引用返回,与作为指针返还的 ULDatabaseSchema、ULTableSchema 和 ULIndexSchema 类不同。不可以关闭返回常量引用的类,但必须关闭作为指针返回的类。
以下代码演示了模式类关闭的恰当和不当使用:
// 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(); |
![]() |
使用DocCommentXchange 讨论此页。
|
版权 © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |