IBM Books

What's New


Functions

The following CLI functions have been added or enhanced:

SQLBuildDataLink - Build DATALINK Value

Purpose


Specification: DB2 CLI 5.2   ISO CLI

SQLBuildDataLink() returns a DATALINK value built from input arguments.

Syntax

SQLRETURN   SQLBuildDataLink(SQLHSTMT          StatementHandle,
                             SQLCHAR     FAR   *LinkType,
                             SQLINTEGER        LinkTypeLength,
                             SQLCHAR     FAR   *DataLocation,
                             SQLINTEGER        DataLocationLength,
                             SQLCHAR     FAR   *Comment,
                             SQLINTEGER        CommentLength,
                             SQLCHAR     FAR   *DataLinkValue,
                             SQLINTEGER        BufferLength,
                             SQLINTEGER  FAR   *StringLengthPtr);

Function Arguments

Table 1. SQLBuildDataLink Arguments
Data Type Argument Use Description
SQLHSTMT StatementHandle input Used only for diagnostic reporting.
SQLCHAR * LinkType input Always set to SQL_DATALINK_URL.
SQLINTEGER LinkTypeLength input The length of the LinkType value.
SQLCHAR * DataLocation input The complete URL value to be assigned.
SQLINTEGER DataLocationLength input The length of the DataLocation value.
SQLCHAR * Comment input The comment, if any, to be assigned.
SQLINTEGER CommentLength input The length of the Comment value.
SQLCHAR * DataLinkValue output The DATALINK value that is created by the function.
SQLINTEGER BufferLength input Length of the DataLinkValue buffer.
SQLINTEGER *StringLengthPtr output A pointer to a buffer in which to return the total number of bytes (excluding the null-termination character) available to return in *DataLinkValue. If DataLinkValue is a null pointer, no length is returned. If the number of bytes available to return is greater than BufferLength minus the length of the null-termination character, then SQLSTATE 01004 is returned. In this case, subsequent use of the DATALINK value may fail.

Usage

The function is used to build a DATALINK value. The maximum length of the string, including the null termination character, will be BufferLength bytes.

Return Codes

Diagnostics

Table 2. SQLGetDatLinkAttr SQLSTATEs
SQLSTATE Description Explanation
01000 Warning. An error occurred for which there was no specific SQLSTATE. The error message returned by SQLGetDiagRec() in the *MessageText buffer describes the error and its cause.
01004 Data truncated. The data returned in *DataLinkValue was truncated to be BufferLength minus the length of the null termination character. The length of the untruncated string value is returned in *StringLengthPtr. (Function returns SQL_SUCCESS_WITH_INFO.)
HY000 General error. An error occurred for which there was no specific SQLSTATE. The error message returned by SQLGetDiagRec() in the *MessageText buffer describes the error and its cause.
HY001 Memory allocation failure. DB2 CLI was unable to allocate memory required to support execution or completion of the function.
HY090 Invalid string or buffer length. The value specified one of the arguments (LinkTypeLength, DataLocationLength, or CommentLength) was less than 0 but not equal to SQL_NTS or BufferLength is less than 0.

Restrictions

None.

References

SQLGetDataLinkAttr - Get Datalink Attribute Value

Purpose


Specification: DB2 CLI 5.2   ISO CLI

SQLGetDataLinkAttr() returns the current value of an attribute of a datalink value.

Syntax

SQLRETURN   SQLGetDataLinkAttr(SQLHSTMT          StatementHandle,
                               SQLSMALLINT       Attribute,
                               SQLCHAR     FAR   *DataLink,
                               SQLINTEGER        DataLinkLength,
                               SQLPOINTER        *ValuePtr,
                               SQLINTEGER        BufferLength,
                               SQLINTEGER  FAR   *StringLengthPtr);

Function Arguments

Table 3. SQLGetDataLinkAttr Arguments
Data Type Argument Use Description
SQLHSTMT StatementHandle input Used only for diagnostic reporting.
SQLSMALLINT Attribute input Identifies the attribute of the DataLink that is to be extracted. Possible values are:
SQL_ATTR_DATALINK_COMMENT
SQL_ATTR_DATALINK_LINKTYPE
SQL_ATTR_DATALINK_URLCOMPLETE 
   (complete URL to access a file)
SQL_ATTR_DATALINK_URLPATH 
   (to access a file within a file server)
SQL_ATTR_DATALINK_URLPATHONLY
   (file path only)
SQL_ATTR_DATALINK_URLSCHEME
SQL_ATTR_DATALINK_URLSERVER
SQLCHAR * DataLink input The DATALINK value from which the attribute is to be extracted.
SQLINTEGER DataLinkLength input The length of the DATALINK value.
SQLPOINTER * ValuePtr output A pointer to memory in which to return the value of the attribute specified by Attribute.
SQLINTEGER BufferLength input Length of the Attribute buffer.
SQLINTEGER *StringLength output A pointer to a buffer in which to return the total number of bytes (excluding the null-termination character) available to return in *Attribute. If Attribute is a null pointer, no length is returned. If the number of bytes available to return is greater than BufferLength minus the length of the null-termination character, then SQLSTATE HY090 is returned.

Usage

The function is used with a DATALINK value that was retrieved from the database or built using SQLBuildDataLink. The AttrType value determines the attribute from the DATALINK value that is returned. The maximum length of the string, including the null termination character, will be BufferLength bytes.

Return Codes

Diagnostics

Table 4. SQLGetDatLinkAttr SQLSTATEs
SQLSTATE Description Explanation
01000 Warning. Informational message. (Function returns SQL_SUCCESS_WITH_INFO.)
HY000 General error. An error occurred for which there was no specific SQLSTATE. The error message returned by SQLGetDiagRec() in the *MessageText buffer describes the error and its cause.
01004 Data truncated. The data returned in *ValuePtr was truncated to be BufferLength minus the length of the null termination character. The length of the untruncated string value is returned in *StringLengthPtr. (Function returns SQL_SUCCESS_WITH_INFO.)
HY001 Memory allocation failure. DB2 CLI was unable to allocate memory required to support execution or completion of the function.
HY009 Invalid argument value. The value specified for the argument *DataLink was a null pointer or was not valid.
HY090 Invalid string or buffer length. The value specified for the argument BufferLength was less than 0 or the values specified for the argument DataLinkLength was less than 0 and not equal to SQL_NTS.
HY092 Option type out of range. The value specified for the argument AttrType was not valid.

Restrictions

None.

References

SQLDriverConnect() and NEWPWD Support

A new attribute-keyword, NEWPWD, has been added to the SQLDriverConnect() function. The syntax diagram in the 'Usage' section has been updated to include the new keyword, and to fix the mistake in the Version 5 book (the separator should be a semi-colon, not a comma).

   .-;------------------------------------------.
   V                                            |
>>-----+-DSN---------------------+=--attribute--+--------------><
       +-UID---------------------+
       +-PWD---------------------+
       +-NEWPWD------------------+
       '-DB2 CLI-defined-keyword-'
 

This new entry is defined as follows:

NEWPWD
New password used as part of a change password request.

The application can either specify the new string to use, for example, NEWPWD=anewpass;; or specify NEWPWD=; and rely on a dialog box generated by the DB2 CLI driver to prompt for the new password (set the DriverCompletion argument to anything other than SQL_DRIVER_NOPROMPT).

SQLBrowseConnect() and NEWPWD Support

The attribute-keyword NEWPWD has been added. It has the same description as "SQLDriverConnect() and NEWPWD Support".

SQLGetInfo()

The following change must be made to the description of the values for SQL_GETDATA_EXTENSIONS in SQLGetInfo(). The version 5.0 CLI Guide and Reference incorrectly states that SQL_GD_BLOCK is supported; this is not the case.

The Description and Notes section for SQL_GETDATA_EXTENSIONS should read as follows:

SQL_GETDATA_EXTENSIONS 32-bit mask
Indicates whether extensions to the SQLGetData() function are supported. The following extensions are currently identified and supported by DB2 CLI:

ODBC also defines the following extensions which are not returned by DB2 CLI:

SQLGetLength()

The description of the StringLength argument has been updated as follows:

The length of the large object (LOB, CLOB, etc...) referenced by the Locator argument. This value is in bytes, even for DBCLOB data.

SQLSetConnectAttr() - Additional Connection Attributes

The following connection attributes have been added to SQLSetConnectAttr():

In Chapter 5 "Functions", in the section SQLSetConnectAttr(), Table 147 "When Connection Attributes can be Set" has been updated to include the following new rows:

Table 5. When Connection Attributes can be Set
Attribute Before connection After connection After statements allocated
SQL_ATTR_ENLIST_IN_DTC No Yes Yes
SQL_ATTR_INFO_USERID No Yes Yes
SQL_ATTR_INFO_WRKSTNNAME No Yes Yes
SQL_ATTR_INFO_APPLNAME No Yes Yes
SQL_ATTR_INFO_ACCTSTR No Yes Yes

Also, in the section "Attribute *ValuePtr Contents" for SQLSetConnectAttr(), the following new information has been added:

SQL_ATTR_ENLIST_IN_DTC (DB2 CLI v5)

An SQLPOINTER which can be either:

Each time this attribute is used with a non-null transaction pointer, the previous transaction is assumed to be ended and a new transaction is initiated. The application must call the ITransaction member function Endtransaction before calling this API with a non-null pointer. Otherwise the previous transaction will be aborted. The application can enlist mutiple connections with the same transaction pointer.
Note:This connection attribute is specified by MTS automatically for each transaction and is not coded by the user application.
There must not be concurrent SQL statements executing on 2 different connections into the same database within the same distributed unit of work (DUOW).

SQL_ATTR_INFO_USERID (DB2 CLI v5)

A null-terminated character string used to identify the client user ID sent to the host database server when using DB2 Connect.

Usage notes:

Note:This is an IBM defined extension.

SQL_ATTR_INFO_WRKSTNNAME (DB2 CLI v5)

A null-terminated character string used to identify the client workstation name sent to the host database server when using DB2 Connect.

Usage notes:

Note:This is an IBM defined extension.

SQL_ATTR_INFO_APPLNAME (DB2 CLI v5)

A null-terminated character string used to identify the client application name sent to the host database server when using DB2 Connect.

Usage notes:

Note:This is an IBM defined extension.

SQL_ATTR_INFO_ACCTSTR (DB2 CLI v5)

A null-terminated character string used to identify the client accounting string sent to the host database server when using DB2 Connect.

Usage notes:

Note:This is an IBM defined extension.

SQLSetStmtAttr()

The original Version 5 documentation for the the SQLSetStmtAttr() function concerning the SQL_ATTR_CURSOR_TYPE statement contained one mistake. If SQL_ATTR_CURSOR_TYPE is set to either SQL_CURSOR_KEYSET_DRIVEN or SQL_CURSOR_DYNAMIC (neither supported by DB2 CLI) then the value used will be SQL_CURSOR_STATIC, not SQL_CURSOR_FORWARD_ONLY as originally documented.

The complete documentation is as follows:

SQL_ATTR_CURSOR_TYPE (DB2 CLI v2)

A 32-bit integer value that specifies the cursor type. The supported values are:

The default value is SQL_CURSOR_FORWARD_ONLY.

This option cannot be specified for an open cursor.

For more detailed information, the application should call SQLGetInfo() with an InfoType of SQL_<cursor type>_ATTRIBUTES1 and SQL_<cursor type>_ATTRIBUTES2 (SQL_STATIC_CURSOR_ATTRIBUTES2, for instance).

Note:The following values have also been defined by ODBC, but are not supported by DB2 CLI:
  • SQL_CURSOR_KEYSET_DRIVEN
  • SQL_CURSOR_DYNAMIC

If either of these values is used, DB2 CLI sets the statement attribute to SQL_CURSOR_STATIC and returns SQLSTATE 01S02 (Option value changed). In this case the application should call SQLGetStmtAttr() to query the actual value.


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

[ DB2 List of Books | Search the DB2 Books ]