Call Level Interface Guide and Reference

SQLSetCursorName - Set Cursor Name

Purpose


Specification: DB2 CLI 1.1 ODBC 1.0 ISO CLI

SQLSetCursorName() associates a cursor name with the statement handle. This function is optional since DB2 CLI implicitly generates a cursor name when each statement handle is allocated.

Syntax

SQLRETURN   SQLSetCursorName (SQLHSTMT          StatementHandle,
                              SQLCHAR      FAR  *CursorName,
                              SQLSMALLINT       NameLength);

Function Arguments

Table 154. SQLSetCursorName Arguments
Data Type Argument Use Description
SQLHSTMT StatementHandle input Statement handle
SQLCHAR * CursorName input Cursor name
SQLSMALLINT NameLength input Length of contents of CursorName argument

Usage

DB2 CLI always generates and uses an internally generated cursor name when a query is prepared or executed directly. SQLSetCursorName() allows an application defined cursor name to be used in an SQL statement (a Positioned UPDATE or DELETE). DB2 CLI maps this name to the internal name. The name will remain associated with the statement handle, until the handle is dropped, or another SQLSetCursorName() is called on this statement handle.

Although SQLGetCursorName() will return the name set by the application (if one was set), error messages associated with positioned UPDATE and DELETE statements will refer to the internal name. For this reason, we recommend that you do not use SQLSetCursorName(), but instead use the internal name which can be obtained by calling SQLGetCursorName().

Cursor names must follow these rules:

For efficient processing, applications should not include any leading or trailing spaces in the CursorName buffer. If the CursorName buffer contains a delimited identifier, applications should position the first double quote as the first character in the CursorName buffer.

Return Codes

Diagnostics

Table 155. SQLSetCursorName SQLSTATEs
SQLSTATE Description Explanation
34000 Invalid cursor name. The cursor name specified by the argument CursorName was invalid. The cursor name either begins with "SQLCUR" or "SQL_CUR" or violates the 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 CursorName already exists.

The cursor name length is greater than the value returned by SQLGetInfo() with the SQL_MAX_CURSOR_NAME_LEN argument.

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 memory required to support execution or completion of the function.
HY009 Invalid argument value. CursorName was a null pointer.
HY010 Function sequence error. There is an open or positioned cursor on the statement handle.

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

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

An asynchronously executing function (not this one) was called for the StatementHandle and was still executing when this function was called.

HY013 Unexpected memory handling error. DB2 CLI was unable to access memory required to support execution or completion of the function.
HY090 Invalid string or buffer length. The argument NameLength was less than 0, but not equal to SQL_NTS.

Authorization

None.

CLI Sample tbmod.c

(The complete sample tbmod.c is also available here .)

 
/* From the CLI sample TBMOD.C */
/* ... */
 
    /* set the name of the cursor */    
    rc = SQLSetCursorName(hstmtSelect, (SQLCHAR *)"CURSNAME", SQL_NTS);
    STMT_HANDLE_CHECK( hstmtSelect, sqlrc);
    
 

References


[ Top of Page | Previous Page | Next Page ]