Version 9.7 includes new enhancements that extend the CLI functionality that can improve the performance and reliability of applications that use CLI.
You can now use the CLI statement attribute SQL_ATTR_ROWCOUNT_PREFETCH to enable a CLI application to retrieve a full row count before fetching.
Before the introduction of this feature, calling the SQLRowCount function on a non-scrollable SELECT-only cursor set the contents of RowCountPtr to -1 because the number of rows was not available until all of the data had been fetched.
This support is also available in Version 9.5 Fix Pack 3 and later fix packs.
You can use the new SQLCreatePkg API to bind arbitrary packages to a database. You can control some BIND options by using this API.
This support is also available in Version 9.5 Fix Pack 3 and later fix packs.
CLI applications can now override the default packet size that is used to ping a database and specify the number of times to ping the database before yielding a final result.
Before the introduction of this feature, the packet size was fixed, and you could ping a database one time only. These limitations made it more difficult for you to understand network complexities and judge system performance. With the new enhancements, you have finer control over the ping operation and can view accurate, more meaningful results.
The application must call the SQLSetConnectAttr function to set these attributes on a connection handle before pinging a database. If you specify a value greater than 1 for the SQL_ATTR_PING_NTIMES attribute, CLI returns the average time that it took to ping the database over all iterations.
To get the current values for the new attributes, call the SQLGetConnectAttr function and pass SQL_ATTR_PING_NTIMES as the attribute argument.
This support is also available in Version 9.5 Fix Pack 3 and later fix packs.
You can help improve the performance of CLI applications that use the LOAD API by using the new SQL_ATTR_LOAD_MODIFIED_BY statement attribute to specify the anyorder file type modifier. Use the statement attribute to specify multiple file type modifiers that are separated by spaces.
char *filemod="anyorder";
SQLSetStmtAttr (hstmt, SQL_ATTR_LOAD_MODIFIED_BY,
(SQLPOINTER) filemod, SQL_NTS);
You can suppress header information that is typically displayed in a CLI trace by setting the new SQL_ATTR_TRACENOHEADER environment attribute to 1. When you specify 1 for this attribute, no header information is written to the CLI trace log file. The default value for this attribute is 0.
[ Process: 1856, Thread: -1229691200 ]
[ Date & Time: 07/03/2008 14:43:53.074965 ]
[ Product: QDB2/LINUX DB2 v9.1.0.4 ]
[ Level Identifier: 01050107 ]
[ CLI Driver Version: 09.01.0000 ]
[ Informational Tokens: "DB2 v9.1.0.4","s080122","MI00228","Fixpack4" ]
[ Install Path: /opt/IBM/db2/V9.1.0.4 ]
[ db2cli.ini Location: /xxx/ramdisk2/db/cli/db2cli.ini ]
You can control whether dynamic statements that contain literal values use the statement cache by setting the new StmtConcentrator CLI/ODBC configuration keyword or the new statement attribute SQL_ATTR_STMT_CONCENTRATOR.
By default, CLI applications use the behavior that is specified on the server.
CLI applications that access DB2® for z/OS® can now roll back a transaction even while in SQL_NEED_DATA state by setting the new SQL_ATTR_FORCE_ROLLBACK connection attribute by using the SQLSetConnectAttr API. This behavior is supported when the StreamPutData CLI/ODBC configuration keyword is set to 1.
Before this enhancement, CLI applications running on DB2 for z/OS had to drop and reestablish the database connection to come out of the SQL_NEED_DATA state.
When querying data servers that support the Dynamic Data Format, CLI applications can now call for previously accessed LOB columns, and maintain the data offset position from the previous SQLGetData() call. You control this behavior by specifying the new AllowInterleavedGetData CLI/ODBC configuration keyword or the new SQL_ATTR_ALLOW_INTERLEAVED_GETDATA statement attribute.
Before this enhancement, CLI applications could call SQLGetData() for previously accessed LOB, if you specified the AllowGetDataLOBReaccess CLI/ODBC configuration keyword. However, there was no way to maintain the data position and offset information.
CALL addEmp(?,?,?,?);
CALL addEmp(:empNo, :empName, :empDeptNo, :empAddr);
Before this enhancement, you could not pass procedure arguments in an order that differed from the order in which you defined the parameters when creating the procedure.
CLI provides no support to bind by name. CLI processes anything that matches a valid parameter marker, and treats it as if it is a normal parameter marker, which is represented by a question mark (?).
To enable CLI support for named parameter processing, set the new EnableNamedParameterSupport CLI/ODBC configuration keyword to TRUE. By default, named parameter processing is disabled in the IBM® Data Server Driver for ODBC and CLI for all servers.
When you use the CALL statement to call a procedure, you no longer have to specify values for all the parameters. Unspecified parameters take the default values that you defined for the procedure.
CREATE PROCEDURE addEmp (
IN empNo INTEGER DEFAULT 100,
IN empName VARCHAR(20) DEFAULT 'nothing',
IN empDeptNo INTEGER DEFAULT 2,
IN empAddr VARCHAR(100) DEFAULT 'San Jose, CA'
) ...
When you call this procedure in a CLI application,
you can omit specifying a value for any parameter that has a default
value. The value for the missing parameter is supplied by the server.
Therefore, the following example no longer results in an error:CALL addEmp (empName => 'John',
empDeptNo => 1,
empAddr => 'Bangalore')
BEGIN
INSERT INTO T0 VALUES (V0);
INSERT INTO T1 VALUES (V1);
END
Compound SQL statements are not supported if you use CLI array input chaining.
You can now use the ConcurrentAccessResolution CLI/ODBC configuration keyword to specify a prepare attribute that overrides the behavior specified for cursor stability (CS) scans. You can choose to use currently committed semantics, wait for the outcome of the transaction, or skip locked data. This setting overrides the default behavior for currently committed semantic that is defined by the cur_commit configuration parameter.
SQL data type | C data type |
---|---|
SQL_BIGINT |
SQL_C_DBCHAR |
SQL_TYPE_DATE | SQL_C_TYPE_TIMESTAMP |
SQL_TYPE_TIME | SQL_C_TYPE_TIMESTAMP |
SQL_TYPE_TIMESTAMP | SQL_C_CHAR |
The new SQL_ATTR_REPORT_TIMESTAMP_TRUNC_AS_WARN CLI statement attribute is also available to control whether a datetime overflow results in an error (SQLSTATE 22008) or warning (SQLSTATE 01S07).
CLI applications can now use the SQLCreateDb() and SQLDropDb() APIs to add and drop databases. You can use the equivalent SQLCreateDbW() and SQLDropDbW() APIs with UNICODE CLI applications for adding and dropping databases.
DB2 Database servers must connect to the database instance by using the ATTACH configuration keyword.
The new ATTACH configuration keyword allows SQLDriverConnect() to attach to a server instance instead of a database. CLI applications can now use this configuration keyword when connecting to a DB2 Linux, Unix, and Windows database server.
The new connection level attribute SQL_ATTR_OVERRIDE_CHARACTER_CODEPAGE enables CLI applications to specify a database code page even when the code page is not available at the client end. When this new attribute is set to non-zero value, CLI will skip code page conversion during bind-in or bind-out of character data. CLI will fetch/insert the raw data without performing conversion from/to the server.
The statementConcentrator property for connection and statement attributes, which controls whether statement cache is used for dynamic statement containing literal values, now applies to connections to DB2 for z/OS Version 10.
DB2 for z/OS Version 10 supports the new TIMESTAMP_WITH_TIMEZONE data type. The new TIMESTAMP_WITH_TIMEZONE data type is only available in new function mode.
The SQL_ATTR_EXTENDED_INDICATORS statement attribute that eliminates the need to indicate the position in the SQL statement can now be used by CLI applications for connections to DB2 for z/OS Version 10.
DB2Explain CLI configuration keyword support which is available for DB2 for Linux, UNIX, and Windows, data server is now extended to DB2 for z/OS Version 10 servers.
Currently committed semantic support which is available for DB2 Linux, UNIX, and Windows data server is now extended to DB2 for z/OS Version 10 servers. The z/OS server, however, currently only supports query against uncommitted INSERT and uncommitted DELETE.
The DB2 for z/OS Version 10 New Function Mode supports the binary XML format. CLI now provides a pass through mechanism for Binary XML data format.
Version 9.7 Fix Pack 4 and later fix packs include the following enhancements to the CLI:
Version 9.7 Fix Pack 4 and later fix packs include the following enhancements to the CLI:
When you modify the db2dsdriver.cfg file, your CLI application can call the SQLReloadConfig function to validate the entries for all alternate servers within the <acr> section. For each server, an attempt is made to open a socket by using the specified host name and port. If all servers in the alternate server list for an active database connection are unreachable, an error message is returned in the DiagInfoString argument of the SQLReloadConfig function.
Version 9.7 Fix Pack 4 and later fix packs include the following enhancements to the CLI:
The validate option of the db2cli command has been enhanced so that invalid keywords found in the db2cli.ini and db2dsdriver.cfg files are displayed as well as valid keywords.
In Version 9.7 Fix Pack 5 and later fix packs, CLI applications support the following features to improve application performance, troubleshooting, and high availability:
In Version 9.7 Fix Pack 5 and later fix packs, the following changes apply to thedb2cli command:
In Version 9.7 Fix Pack 5 and later fix packs, the following changes or additions have been made to support ODBC 3.8:
In Version 9.7 Fix Pack 6 and later fix packs, you can obtain the server time for COMMIT or ROLLBACK SQL operations on DB2 for z/OS Version 10 and later. SeeConnection attributes (CLI) list.
In Version 9.7 Fix Pack 6 and later fix packs, the new SQL_C_CURSORHANDLE C data type is available for use with the SQL_CURSORHANDLE SQL data type. See SQL symbolic and default data types for CLI applications.
In Version 9.7 Fix Pack 6 and later fix packs, the CLI driver now supports use of the QueryTimeout keyword in the db2dsdriver.cfg file. See QueryTimeout IBM Data Server Driver configuration keyword.