SQLSetCursorName - Set cursor name

 

SQLSetCursorName() associates a cursor name with the statement handle. This function is optional because DB2® UDB CLI implicitly generates a cursor name when needed.

 

Syntax

SQLRETURN SQLSetCursorName (SQLHSTMT       hstmt,
                            SQLCHAR        *szCursor,
                            SQLSMALLINT    cbCursor);

 

Function arguments

Table 1. SQLSetCursorName arguments
Data type Argument Use Description
SQLHSTMT hstmt Input Statement handle.
SQLCHAR * szCursor Input Cursor name.
SQLSMALLINT cbCursor Input Length of contents of szCursor argument.

 

Usage

DB2 UDB CLI always generates and uses an internally generated cursor name when a SELECT statement is prepared or processed directly. SQLSetCursorName() allows an application-defined cursor name to be used in an SQL statement (a Positioned UPDATE or DELETE). DB2 UDB CLI maps this name to an internal name. SQLSetCursorName() must be called before an internal name is generated. The name remains associated with the statement handle, until the handle is dropped. The name also remains after the transaction has ended, but at this point SQLSetCursorName() can be called to set a different name for this statement handle. Cursor names must follow the following rules:

 

Return codes

 

Diagnostics

Table 2. SQLSetCursorName SQLSTATEs
SQLSTATE Description Explanation
34000 Cursor name that is not valid The cursor name specified by the argument szCursor is not valid. The cursor name either begins with "SQLCUR" or "SQL_CUR" or violates either the driver or the data source cursor naming rules (Must begin with a-z or A-Z followed by any combination of English letters, digits, or the '_' character.

The cursor name specified by the argument szCursor exists.

58004 System error Unrecoverable system error.
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 szCursor is a null pointer.

The argument cbCursor is less than 1, but not equal to SQL_NTS.

HY010 Function sequence error The statement handle is not in allocated state.

SQLPrepare() or SQLExecDirect() is called before SQLSetCursorName().

HY013 * Memory management problem The driver is unable to access memory required to support the processing or completion of the function.

 

References

SQLGetCursorName - Get cursor name

 

Parent topic:

DB2 UDB CLI functions