没有合适的资源?快使用搜索试试~ 我知道了~
首页DB2 CLI指南与参考:第二卷,创建数据库应用与函数详解
DB2官方手册:调用级别接口(CLI)指南和引用(第二卷/两卷版)是专为DB2 for Linux, UNIX, and Windows平台设计的文档,旨在帮助开发人员深入了解和利用Call Level Interface (CLI)来创建高效且功能强大的数据库应用程序。该手册分为两个部分,每个部分都具有其独特的重点。 第一卷主要侧重于实践指导,它详细介绍了如何通过CLI进行数据库应用开发。这部分内容涵盖了从基础操作到高级技术的全面教学,包括但不限于连接数据库、执行SQL语句、处理数据事务、创建存储过程和触发器等。此外,它还会讨论如何在不同操作系统环境下适配和优化CLI的使用,确保跨平台的一致性。 第二卷则作为参考手册,深入剖析了CLI的具体功能、关键字以及配置选项。读者可以在这里查找关于各种CLI函数的详细描述,了解它们的工作原理,以及如何正确地在代码中调用这些功能。这部分内容对开发人员来说,是调试和优化CLI程序的强大工具,有助于提升代码质量和性能。 值得注意的是,这份指南更新至2014年10月,包含了重要的安全性和兼容性信息,使用者在使用前应阅读附录B中的"注意事项",了解相关的版权法律和产品支持要求。此外,IBM提供了在线订购和联系当地代表的方式,以便获取最新的文档和产品支持。 总体而言,DB2 CLI指南和引用第二卷是一本实用且权威的工具书,无论是初次接触CLI的开发者还是经验丰富的DB2专家,都能从中找到有价值的信息,提升在DB2平台上开发数据库应用的能力。
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/11671939/bg10.jpg)
Table 1. CLI Function list by category (continued)
Task
Function name
ODBC
3.0
SQL/
CLI
CLI
first version
supported Purpose
SQLCopyDesc() Core 95 V5 Copies descriptor information between
handles.
SQLGetDescField() Core 95 V5 Gets single field settings of a descriptor
record.
SQLGetDescRec() Core 95 V5 Gets multiple field settings of a descriptor
record.
SQLSetDescField() Core 95 V5 Sets a single field of a descriptor record.
SQLSetDescRec() Core 95 V5 Sets multiple field settings of a descriptor
record.
Large object support
SQLBindFileToCol() No No V2.1 Associates a LOB file reference with a LOB
column.
SQLBindFileToParam() No No V2.1 Associates a LOB file reference with a
parameter marker.
SQLGetLength() No SQL3 V2.1 Gets the length of a string referenced by a
LOB locator.
SQLGetPosition() No SQL3 V2.1 Gets the position of a string within a
source string referenced by a LOB locator.
SQLGetSubString() No SQL3 V2.1 Creates a new LOB locator that references
a substring within a source string. The
source string is also represented by a LOB
locator.
Obtaining information about the data source's system tables (catalog functions)
SQLColumns() Lvl 1 SQL3 V2.1
1
Returns the list of column names in
specified tables.
SQLExtendedProcedures() No No V9.7 Returns the list of procedure names stored
in a specific data source with additional
information.
SQLExtendedProcedureColumns() No No V9.7 Returns the list of input and output
parameters for the specified procedures
with additional information.
SQLForeignKeys() Lvl 2 SQL3 V2.1 Returns the list of column names that
comprise foreign keys, if they exist for a
specified table.
SQLPrimaryKeys() Lvl 1 SQL3 V2.1 Returns the list of column names that
comprise the primary key for a table.
SQLProcedureColumns() Lvl 2 No V2.1 Returns the list of input and output
parameters for the specified procedures.
SQLProcedures() Lvl 2 No V2.1 Returns the list of procedure names stored
in a specific data source.
SQLSpecialColumns() Core SQL3 V2.1
1
Returns information about the optimal set
of columns that uniquely identifies a row
in a specified table.
SQLStatistics() Core SQL3 V2.1
1
Returns statistics about a single table and
the list of indexes associated with the table.
CLI and ODBC function summary
4
Call Level Interface Guide and Reference Volume 2
![](https://csdnimg.cn/release/download_crawler_static/11671939/bg11.jpg)
Table 1. CLI Function list by category (continued)
Task
Function name
ODBC
3.0
SQL/
CLI
CLI
first version
supported Purpose
SQLTablePrivileges() Lvl 2 SQL3 V2.1 Returns a list of tables and the privileges
associated with each table.
SQLTables() Core SQL3 V2.1
1
Returns the list of table names stored in a
specific data source.
Terminating a statement
SQLFreeHandle() Core 95 V1.1 Frees handle resources.
SQLFreeStmt() Core 95 V1.1 Ends statement processing and closes the
associated cursor, discards pending results,
and, optionally, frees all resources
associated with the statement handle.
SQLCancel() Core 95 V1.1 Cancels an SQL statement.
SQLTransact() Depr No V1.1 Commits or rolls back a transaction.
SQLCloseCursor() Core 95 V5 Commits or rolls back a transaction.
Terminating a connection
SQLDisconnect() Core 95 V1.1 Closes the connection.
SQLEndTran() Core 95 V5 Ends the transaction of a connection.
SQLFreeConnect() Depr 95 V1.1 Releases the connection handle.
SQLFreeEnv() Depr 95 V1.1 Releases the environment handle.
Creating and dropping a database
SQLCreateDb() No No V9.7 Creates a database based on the specified
database name, code-set, and mode.
SQLDropDb() No No V9.7 Drops the specified database.
Note:
1
Runtime support for this function was also available in the DB2 Client Application Enabler for DOS
Version 1.2 product.
2
SQLBindParam() has been replaced by SQLBindParameter().
Depr in the ODBC column indicates that the function has been deprecated for ODBC.
The following limitations apply to ODBC functions:
v SQLSetScrollOptions() is supported for runtime use only, because it has been superseded by the
SQL_CURSOR_TYPE, SQL_CONCURRENCY, SQL_KEYSET_SIZE, and SQL_ROWSET_SIZE statement options.
v SQLDrivers() is implemented by the ODBC driver manager.
Unicode functions (CLI)
CLI Unicode functions accept Unicode string arguments in place of ANSI string
arguments. The Unicode string arguments must be in UCS-2 encoding
(native-endian format).
ODBC API functions have suffixes to indicate the format of their string arguments:
those that accept Unicode end in W, and those that accept ANSI have no suffix
CLI and ODBC function summary
Chapter 1. CLI and ODBC functions 5
![](https://csdnimg.cn/release/download_crawler_static/11671939/bg12.jpg)
(ODBC adds equivalent functions with names that end in A, but these are not
offered by CLI). The following list of CLI functions are available in both ANSI and
Unicode versions:
v SQLBrowseConnect
v SQLColAttribute
v SQLColAttributes
v SQLColumnPrivileges
v SQLColumns
v SQLConnect
v SQLCreateDb
v SQLCreatePkg
v SQLDataSources
v SQLDescribeCol
v SQLDriverConnect
v SQLDropDb
v SQLError
v SQLExecDirect
v SQLExtendedPrepare
v SQLExtendedProcedures
v SQLExtendedProcedureColumns
v SQLForeignKeys
v SQLGetConnectAttr
v SQLGetConnectOption
v SQLGetCursorName
v SQLGetDescField
v SQLGetDescRec
v SQLGetDiagField
v SQLGetDiagRec
v SQLGetInfo
v SQLGetPosition
v SQLGetStmtAttr
v SQLNativeSQL
v SQLPrepare
v SQLPrimaryKeys
v SQLProcedureColumns
v SQLProcedures
v SQLReloadConfig
v SQLSetConnectAttr
v SQLSetConnectOption
v SQLSetCursorName
v SQLSetDescField
v SQLSetStmtAttr
v SQLSpecialColumns
v SQLStatistics
v SQLTablePrivileges
Unicode functions (CLI)
6
Call Level Interface Guide and Reference Volume 2
![](https://csdnimg.cn/release/download_crawler_static/11671939/bg13.jpg)
v SQLTables
For unicode functions that take a string length as an argument, the length is
calculated as the number of SQL_WCHAR elements that are needed to store the
string. For unicode functions that return string data from the server, the returned
length of the string data is the number of SQL_WCHAR elements that are needed
to store the string. However, the length of data that can be a string or non-string is
calculated in number of bytes that are needed to store the data.
For example, the SQLGetInfoW() API takes the length as the number of bytes
while the SQLExecDirectW() function interprets the length as the number of
SQL_WCHAR elements. On Windows operating systems, where the UTF-16
extended character set is used, the single character SQL_WCHAR is equivalent to 2
SQL_C_CHAR elements. Each SQL_C_CHAR element has length of 2 bytes. The
CLI driver returns data from the result sets in either unicode or ANSI, depending
on the API called by the application and the data that are bound. If an application
binds data to a SQL_C_CHAR type, the CLI driver converts SQL_WCHAR data to
SQL_CHAR in the unicode function.
ANSI to Unicode function mappings
The syntax for a CLI Unicode function is the same as the syntax for its
corresponding ANSI function, except that SQL_CHAR parameters are defined as
SQL_WCHAR. Character buffers defined as SQLPOINTER in the ANSI syntax can
be defined as either SQL_CHAR or SQL_WCHAR in the unicode function.
SQLAllocConnect function (CLI) - Allocate connection handle
In ODBC 3.0, SQLAllocConnect() has been deprecated and replaced with
SQLAllocHandle().
Although this version of CLI continues to support SQLAllocConnect(), it is
recommended that you use SQLAllocHandle() in your CLI programs so that they
conform to the latest standards.
Migrating to the new function
The statement:
SQLAllocConnect(henv, &hdbc);
for example, would be rewritten using the new function as:
SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
SQLAllocEnv function (CLI) - Allocate environment handle
In ODBC 3.0, SQLAllocEnv() has been deprecated and replaced with
SQLAllocHandle().
Although this version of CLI continues to support SQLAllocEnv(), use
SQLAllocHandle() in your CLI programs so that they conform to the latest
standards.
Unicode functions (CLI)
Chapter 1. CLI and ODBC functions 7
![](https://csdnimg.cn/release/download_crawler_static/11671939/bg14.jpg)
Migrating to the new function
The statement:
SQLAllocEnv(&henv);
for example, would be rewritten using the new function as:
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
SQLAllocHandle function (CLI) - Allocate handle
Allocates environment, connection, statement, or descriptor handles.
Note: This function replaces the deprecated ODBC 2.0 functions
SQLAllocConnect(), SQLAllocEnv(), and SQLAllocStmt().
Specification:
v CLI 5.0
v ODBC 3.0
v ISO CLI
Syntax
SQLRETURN SQLAllocHandle (
SQLSMALLINT HandleType, /* fHandleType */
SQLHANDLE InputHandle, /* hInput */
SQLHANDLE *OutputHandlePtr); /* *phOutput */
Function Arguments
Table 2. SQLAllocHandle arguments
Data type Argument Use Description
SQLSMALLINT HandleType input The type of handle to be allocated by
SQLAllocHandle(). Must be one of the following
values:
v SQL_HANDLE_ENV
v SQL_HANDLE_DBC
v SQL_HANDLE_STMT
v SQL_HANDLE_DESC
SQLHANDLE InputHandle input Existing handle to use as a context for the new
handle being allocated. If HandleType is
SQL_HANDLE_ENV, this is SQL_NULL_HANDLE.
If HandleType is SQL_HANDLE_DBC, this must be
an environment handle, and if it is
SQL_HANDLE_STMT or SQL_HANDLE_DESC, it
must be a connection handle.
SQLHANDLE * OutputHandlePtr output Pointer to a buffer in which to return the handle to
the newly allocated data structure.
Usage
SQLAllocHandle() is used to allocate environment, connection, statement, and
descriptor handles. An application can allocate multiple environment, connection,
statement, or descriptor handles at any time a valid InputHandle exists.
SQLAllocEnv function (CLI) - Allocate environment handle
8
Call Level Interface Guide and Reference Volume 2
剩余606页未读,继续阅读
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/bb584666001344f2ab0f098bfc9da9ec_qq_35826774.jpg!1)
Alent7
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- Hadoop生态系统与MapReduce详解
- MDS系列三相整流桥模块技术规格与特性
- MFC编程:指针与句柄获取全面解析
- LM06:多模4G高速数据模块,支持GSM至TD-LTE
- 使用Gradle与Nexus构建私有仓库
- JAVA编程规范指南:命名规则与文件样式
- EMC VNX5500 存储系统日常维护指南
- 大数据驱动的互联网用户体验深度管理策略
- 改进型Booth算法:32位浮点阵列乘法器的高速设计与算法比较
- H3CNE网络认证重点知识整理
- Linux环境下MongoDB的详细安装教程
- 压缩文法的等价变换与多余规则删除
- BRMS入门指南:JBOSS安装与基础操作详解
- Win7环境下Android开发环境配置全攻略
- SHT10 C语言程序与LCD1602显示实例及精度校准
- 反垃圾邮件技术:现状与前景
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)