Language cursors versus Client-Library cursors

Table 7-1 compares Transact-SQL (language) cursor commands with Client-Library cursor commands:

Table 7-1: Transact-SQL cursor commands versus Client-Library cursor commands

Operation

Language command

Client-Library cursor command

Declare

declare cursor

ct_cursor(CS_CURSOR_DECLARE) or ct_dynamic(CS_CURSOR_DECLARE)

Set cursor rows

set cursor rows

ct_cursor(CS_CURSOR_ROWS)

Open

open

ct_cursor(CS_CURSOR_OPEN)

Fetch

fetch

ct_fetch or ct_scroll_fetch, after ct_results has returned with a result_type of CS_CURSOR_RESULT.

Update

update ... where current of cursor_name

ct_cursor(CS_CURSOR_UPDATE)

By default, affects the last fetched row, but can be redirected to any previously fetched row.

Delete

delete ... where current of cursor_name

ct_cursor(CS_CURSOR_DELETE)

By default, affects the last fetched row, but can be redirected to any previously fetched row.

Close

close

ct_cursor(CS_CURSOR_CLOSE)

Deallocate

deallocate cursor

ct_cursor(CS_CURSOR_DEALLOC) or ct_cursor(CS_CURSOR_CLOSE)

The cursor is closed and deallocated with one command if the CS_DEALLOC bit is set in ct_cursor’s option parameter.