SQLGetStmtAttr - Get the value of a statement attribute

 

SQLGetStmtAttr() returns the current settings of the specified statement attribute.

These options are set using the SQLSetStmtAttr() function. This function is similar to SQLGetStmtOption(). Both functions are supported for compatibility reasons.

 

Syntax

SQLRETURN SQLGetStmtAttr( SQLHSTMT        hstmt,
                            SQLINTEGER    fAttr,
                            SQLPOINTER    pvParam,
                            SQLINTEGER    bLen,
                            SQLINTEGER    *sLen);

 

Function arguments

Table 1. SQLGetStmtAttr arguments
Data type Argument Use Description
SQLHSTMT hstmt Input Statement handle.
SQLINTEGER fAttr Input Attribute to retrieve. Refer to Table 2 for more information.
SQLPOINTER pvParam Output Pointer to buffer for requested attribute.
SQLINTEGER bLen Input Maximum number of bytes to store in pvParam, if the attribute is a character string; otherwise, unused.
SQLINTEGER * sLen Output Length of output data if the attribute is a character string; otherwise, unused.

 

Usage

Table 2. Statement attributes
fAttr Data type Contents
SQL_ATTR_APP_PARAM_DESC Integer The descriptor handle used by the application to provide parameter values for this statement handle.
SQL_ATTR_APP_ROW_DESC Integer The descriptor handle for the application to retrieve row data using the statement handle.
SQL_ATTR_CURSOR_SCROLLABLE Integer A 32-bit integer value that specifies if cursors opened for this statement handle should be scrollable.

  • SQL_FALSE – Cursors are not scrollable, and SQLFetchScroll() cannot be used against them. This is the default.

  • SQL_TRUE – Cursors are scrollable. SQLFetchScroll() can be used to retrieve data from these cursors.
SQL_ATTR_CURSOR_TYPE Integer A 32-bit integer value that specifies the behavior of cursors opened for this statement handle.

  • SQL_CURSOR_FORWARD_ONLY – Cursors are not scrollable, and SQLFetchScroll() cannot be used against them. This is the default.

  • SQL_DYNAMIC – Cursors are scrollable. SQLFetchScroll() can be used to retrieve data from these cursors.
SQL_ATTR_FOR_FETCH_ONLY Integer This indicates if cursors opened for this statement handle should be read-only.

  • SQL_FALSE - Cursors can be used for positioned updates and deletes. This is the default.

  • SQL_TRUE - Cursors are read-only and cannot be used for positioned updates or deletes.
SQL_ATTR_IMP_PARAM_DESC Integer The descriptor handle used by the CLI implementation to provide parameter values for this statement handle.
SQL_ATTR_IMP_ROW_DESC Integer The descriptor handle used by the CLI implementation to retrieve row data using this statement handle.
SQL_ATTR_ROWSET_SIZE Integer A 32–bit integer value that specifies the number of rows in the rowset. This is the number of rows returned by each call to SQLExtendedFetch(). The default value is 1.

 

Return codes

 

Diagnostics

Table 3. SQLGetStmtAttr SQLSTATEs
SQLSTATE Description Explanation
HY001 Memory allocation failure The driver is unable to allocate memory required to support the processing or completion of the function.
HY009 Argument value that is not valid The argument pvParam is a null pointer.

An fAttr that is not valid value is specified.

HYC00 Driver not capable DB2® UDB CLI recognizes the option but does not support it.

 

Parent topic:

DB2 UDB CLI functions