A SRV_CURDESC structure contains information about a cursor, including:
The cursor’s unique ID
The type of cursor command most recently issued by the client
The status of the cursor
A SRV_CURDESC structure is defined as follows:
/*
** SRV_CURDESC
** The Open Server cursor description
** structure.
*/
typedef struct srv_curdesc
{
CS_INT curid;
CS_INT numupcols;
CS_INT fetchcnt;
CS_INT curstatus;
CS_INT curcmd;
CS_INT cmdoptions;
CS_INT fetchtype;
CS_INT rowoffset;
CS_INT curnamelen;
CS_CHAR curname[CS_MAX_CHAR];
CS_INT tabnamelen;
CS_CHAR tabname[CS_MAX_CHAR];
CS_VOID *userdata;
} SRV_CURDESC;
Table 2-12 describes each field in a SRV_CURDESC structure:
Field name |
Description |
Notes |
---|---|---|
curid |
The current cursor identifier |
The Open Server application must set curid when responding to a CS_CURSOR_DECLARE command from the client. Any subsequent commands from the client that pertain to the declared cursor use curid as an identifier. curid is set to 0 if there is no current cursor identifier or if the client is requesting the status of all available cursors. |
numupcols |
The number of columns in a cursor update clause |
numupcols is set to 0 if there are no update columns. This information is available when the cursor is declared. |
fetchcnt |
The current row fetch count for this cursor— that is, the number of rows that will be sent to the client in response to a CS_CURSOR_FETCH command |
fetchcnt is set when a CS_CURSOR_INFO command is received from the client or is sent to the client in response to such a command. fetchcnt is set to 1 if the client has not explicitly set a row fetch count. If the Open Server application cannot support the requested fetch count, it can set this field to a different value before responding. |
curstatus |
The status of the current cursor |
Open Server sets the cursor status in response to the cursor command received from the client. See “Values for curstatus” for a list of legal values. |
curcmd |
The current cursor command type |
See Table 2-14 for a list of legal values. |
cmdoptions |
Any options associated with the cursor command |
Not all commands have associated options. The value of cmdoptions depends on the cursor command. Table 2-14 describes the possible values for cmdoptions, by command. |
fetchtype |
The type of fetch requested by a client |
fetchtype is described when a CS_CURSOR_FETCH command is received from the client. The valid fetch types and their meanings are as follows:
Requests to an Adaptive Server Enterprise will always have a fetchtype of CS_NEXT. |
rowoffset |
The row position for CS_ABSOLUTE or CS_RELATIVE fetches |
rowoffset is undefined for all other fetch types. rowoffset is set when a CS_CURSOR_FETCH command is received from the client. |
curnamelen |
The length of the cursor name in curname |
curnamelen is zero if curname is not valid. curnamelen returns the length of the cursor name. |
curname |
The name of the current cursor |
|
tabnamelen |
The length of the table name in tabname |
tabnamelen is zero if tabname is not valid. tabnamelen returns the length of the table name. tabnamelen is described when a CS_CURSOR_UPDATE or CS_CURSOR_DELETE command is received from the client. |
tabname |
The table name associated with a cursor update or delete command |
tabname is the table name associated with a cursor update or delete command. tabname is described when a CS_CURSOR_UPDATE or CS_CURSOR_DELETE command is received from the client. |
userdata |
A pointer to private data space |
This field allows applications to associate data with a particular cursor without using global or static variables. Open Server does not manipulate userdata; it is provided only for the convenience of Open Server application programmers. |