Cursors (SQL Server Compact)

Application developers usually use the relation (set)-based nature of SQL to manage data. However, sometimes application developers need the extra control of row-by-row operations. Cursors fulfill that need. In Microsoft SQL Server Compact 4.0, there are a number of different types of cursors that you can use to control row-by-row operations.

Most cursors can be used in conjunction with the query processor. There are a number of different cursor behaviors, such as scrollability, updatability, and sensitivity that also affect the choice of cursor. For more information, see "Cursor Behaviors" in SQL Server Books Online.

Advantages of Using Cursors with the Query Processor

Some advantages of using cursors in conjunction with the query processor are:

  • Efficiency. The query optimizer automatically selects the appropriate query plan, so the developer does not need to design a complex algorithm to access the required data.

  • Adaptability. As data changes or indexes are added or dropped, the query optimizer automatically adapts its behavior by using alternative plans.

  • Fewer errors. Instead of the developer handling data and algorithms in the application, the SQL Server Compact 4.0 Database Engine natively supports the required operations.

Requesting a Cursor

In SQL Server Compact 4.0, it is possible to request a cursor only by using API functions.

In This Section

Topic

Description

Types of Cursors

Describes the cursor types supported by SQL Server Compact 4.0.

Choosing a Cursor Type

Provides information to help you choose an appropriate cursor type.

Cursors and Locking

Provides information about cursors and locking.

Implicit Cursor Conversions

Lists factors that trigger SQL Server Compact 4.0 to implicitly convert a cursor from one type to another

Updating Keyset-driven Cursors

Lists scenarios in which you might or might not be able to update results obtained through an updatable keyset-driven cursor.