Release Notes


40.8 Chapter 5. DB2 CLI Functions

40.8.1 SQLBindFileToParam - Bind LOB File Reference to LOB Parameter

The last parameter - IndicatorValue - in the SQLBindFileToParam() CLI function is currently documented as "output (deferred)". It should be "input (deferred)".

|40.8.2 SQLColAttribute -- Return a Column Attribute

| | |

|The following updates are additions to the "Description" column for the |SQL_DESC_AUTO_UNIQUE_VALUE and SQL_DESC_UPDATABLE arguments: |

|SQL_DESC_AUTO_UNIQUE_VALUE
|SQL_FALSE is returned in NumericAttributePtr for all DB2 SQL |data types. Currently DB2 CLI is not able to determine if a column is |an identity column, therefore SQL_FALSE is always returned. This |limitation does not fully conform to the ODBC specifications. Future |versions of DB2 CLI for Unix and Windows servers will provide auto-unique |support.

|SQL_DESC_UPDATABLE
|Indicates if the column data type is an updateable data type: | |

|40.8.3 SQLGetData - Get Data From a Column

|

|The following text replaces the current sentence that appears under the |Explanation column for SQLSTATE 22007 of the SQLSTATEs table for |SQLGetData:

|Conversion from a string to a datetime format was indicated, but an invalid |string representation or value was specified, or the value was an invalid |date.

|40.8.4 SQLGetInfo - Get General Information

| |

|The following corrects the information in the "Usage" section under |"Information Returned by SQLGetInfo": |

|SQL_DATABASE_NAME (string)
|The name of the current database in use.
|Note:
This string is the same as that returned by the SELECT CURRENT SERVER |statement on non-host systems. For host databases, such as DB2 for |OS/390 or DB2 for OS/400, the string returned is the DCS database name that |was provided when the CATALOG DCS DATABASE DIRECTORY command was issued at the |DB2 Connect gateway. |
|

|40.8.5 SQLGetLength - Retrieve Length of A String Value

| |

|The following corrects the footnote in "Table 113. SQLGetLength |Arguments" :

|Note: a This is in characters for DBCLOB data.

40.8.6 SQLNextResult - Associate Next Result Set with Another Statement Handle

The following text should be added to Chapter 5, "DB2 CLI Functions":

40.8.6.1 Purpose

Specification: DB2 CLI 7.x

40.8.6.2 Syntax

SQLRETURN   SQLNextResult	(SQLHSTMT	StatementHandle1
			 	                         SQLHSTMT	StatementHandle2);

40.8.6.3 Function Arguments


Table 13. SQLNextResult Arguments

Data Type Argument Use Description
SQLHSTMT StatementHandle input Statement handle.
SQLHSTMT StatementHandle input Statement handle.

40.8.6.4 Usage

A stored procedure returns multiple result sets by leaving one or more cursors open after exiting. The first result set is always accessed by using the statement handle that called the stored procedure. If multiple result sets are returned, either SQLMoreResults() or SQLNextResult() can be used to describe and fetch the result set.

SQLMoreResults() is used to close the cursor for the first result set and allow the next result set to be processed, whereas SQLNextResult() moves the next result set to StatementHandle2, without closing the cursor on StatementHandle1. Both functions return SQL_NO_DATA_FOUND if there are no result sets to be fetched.

Using SQLNextResult() allows result sets to be processed in any order once they have been transferred to other statement handles. Mixed calls to SQLMoreResults() and SQLNextResult() are allowed until there are no more cursors (open result sets) on StatementHandle1.

When SQLNextResult() returns SQL_SUCCESS, the next result set is no longer associated with StatementHandle1. Instead, the next result set is associated with StatementHandle2, as if a call to SQLExecDirect() had just successfully executed a query on StatementHandle2. The cursor, therefore, can be described using SQLNumResultSets(), SQLDescribeCol(), or SQLColAttribute().

After SQLNextResult() has been called, the result set now associated with StatementHandle2 is removed from the chain of remaining result sets and cannot be used again in either SQLNextResult() or SQLMoreResults(). This means that for 'n' result sets, SQLNextResult() can be called successfully at most 'n-1' times.

If SQLFreeStmt() is called with the SQL_CLOSE option, or SQLFreeHandle() is called with HandleType set to SQL_HANDLE_STMT, all pending result sets on this statement handle are discarded.

SQLNextResult() returns SQL_ERROR if StatementHandle2 has an open cursor or StatementHandle1 and StatementHandle2 are not on the same connection. If any errors or warnings are returned, SQLError() must always be called on StatementHandle1.

Note:
SQLMoreResults() also works with a parameterized query with an array of input parameter values specified with SQLParamOptions() and SQLBindParameter(). SQLNextResult(), however, does not support this.

40.8.6.5 Return Codes

40.8.6.6 Diagnostics


Table 14. SQLNextResult SQLSTATEs

SQLSTATE Description Explanation
40003 08S01 Communication Link failure. The communication link between the application and data source failed before the function completed.
58004 Unexpected system failure. Unrecoverable system error.
HY001 Memory allocation failure. DB2 CLI is unable to allocate the memory required to support execution or completion of the function.
HY010 Function sequence error.

The function was called while in a data-at-execute (SQLParamData(), SQLPutData()) operation.

StatementHandle2 has an open cursor associated with it.

The function was called while within a BEGIN COMPOUND and END COMPOUND SQL operation.

HY013 Unexpected memory handling error. DB2 CLI was unable to access the memory required to support execution or completion of the function.
HYT00 Time-out expired. The time-out period expired before the data source returned the result set. Time-outs are only supported on non-multitasking systems such as Windows 3.1 and Macintosh System 7. The time-out period can be set using the SQL_ATTR_QUERY_TIMEOUT attribute for SQLSetConnectAttr().

40.8.6.7 Restrictions

Only SQLMoreResults() can be used for parameterized queries.

40.8.6.8 References

|40.8.7 SQLSetEnvAttr - Set Environment Attribute

|

|The following is an additional environment attribute that belongs in the |"Environment Attributes" section under "Usage": |

|SQL_ATTR_KEEPCTX
|A 32-bit integer value that specifies whether the context should be kept |when the environment handle is freed. This attribute should be set at |the environment level. It can be used by mutli-threaded applications to |manage contexts associated with each thread's connections, database |resources, and data transmission. The possible values are: |

|

|Note:
This is an IBM extension. |
|

|40.8.8 SQLSetStmtAttr -- Set Options Related to a Statement

| |

|The following replaces the existing information for the statement attribute |SQL_ATTR_QUERY_TIMEOUT: |

|SQL_ATTR_QUERY_TIMEOUT (DB2 CLI v2)
|A 32-bit integer value that is the number of seconds to wait for an SQL |statement to execute between returning to the application. This option |can be set and used to terminate long running queries. The value of 0 |means there is no time out. DB2 CLI supports non-zero values for all |platforms that support multithreading. |


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]