Types of cursor commands

Table 2-4 summarizes the types of cursor commands a client can issue. The “Command” column in the table shows the value in the CURSOR-COMMAND field of the CURSOR-DESC structure.

Table 2-4: Summary of cursor commands

Command

Action

TDS-CURSOR-DECLARE 0x001

Associate a cursor ID with the body of the cursor.

TDS-CURSOR-OPENCMD 0x002

Execute the body of the cursor and generate a cursor result set.

TDS-CURSOR-FETCH 0x003

Fetch rows from the cursor result set.

TDS-CURSOR-DELETE 0x004

Delete the contents of the current cursor row.

TDS-CURSOR-UPDATE 0x005

Update the contents of the current cursor row.

TDS-CURSOR-INFO 0x006

Report the status of the cursor, or set the cursor row fetch count.

TDS-CURSOR-CLOSE 0x007

Make the cursor result set unavailable. Reopening a cursor regenerates the cursor result set.

TDS-CURSOR-DEALLOC 0x008

Render the cursor nonexistent. A cursor that is deallocated cannot be re-opened.

A typical client application issues cursor commands in the order in which they are listed in Table 2-4, but the order can vary. For example, a client can fetch against a cursor, close the cursor, then reopen and fetch it again.

Because a client and server can exchange information about multiple cursors in a single connection session, they need a means of uniquely identifying each cursor. An Open ServerConnect application responds to a cursor declaration by sending back a unique cursor ID. The ID is an integer. The client and the server refer to the cursor by this ID for the lifetime of the cursor.