Differences between DB-Library and Client-Library cursors

A DB-Library cursor does not correspond to an actual Adaptive Server cursor. Instead, at the time the cursor is declared with dbcursoropen, DB-Library fetches keysets from Adaptive Server “under the covers.” It then builds qualifiers based on the keys for the current row and sends them to Adaptive Server. The server parses the query and returns a result set. When dbcursorfetch is called to retrieve more data, the DB-Library cursor may have to do additional selects. In addition, Adaptive Server may have to parse the query each time dbcursorfetch is called.

A Client-Library cursor corresponds to an actual cursor in Adaptive Server. It is sometimes referred to, therefore, as a native cursor. A new TDS protocol allows Client-Library to interact with the server to manage the cursor.

A Client-Library cursor is faster than a DB-Library cursor because it does not have to send SQL commands to the server, which causes multiple re-parsing of the query. But because the result set remains on the server side, it cannot offer the same options for concurrency control as a DB-Library cursor.

The following table summarizes these and additional differences between the two cursors:

Table A-2: Differences between DB-Library cursors and Client-Library cursors

DB-Library cursor

Client-Library cursor

Cursor row position is defined by the client.

Cursor row position is defined by the server.

Can define optimistic concurrency control (allows dirty reads).

Cannot define optimistic concurrency control (does not allow dirty reads).

Can fetch backward (if CUR_KEYSET or CUR_DYNAMIC is specified for scrollopt during dbcursoropen).

Can only fetch forward.

More memory may be required if you query very large row sizes, unless you specify a smaller number of rows in the fetch buffer during dbcursoropen.

More memory is not required, regardless of how large the row sizes are.

You cannot access an Open Server application unless the application installs the required DB-Library stored procedures.

You can access a version 10.0 (or later) Open Server application that is coded to support cursors.

Slower performance.

Faster performance.