RaimaDB Cursor APIs

A database cursor is a control structure that allows you to traverse and manipulate the records in a database result set or query. It acts as a pointer to a specific row within a result set, allowing you to fetch or modify data efficiently.

Cursors are commonly used in database management systems to work with query results that may contain a large number of rows. By using a cursor, you can retrieve and process data row by row, rather than fetching the entire result set at once. This can be especially useful when dealing with large datasets or when you need to perform operations on each row individually.

Here are some key characteristics and operations associated with cursors:

  1. Declaration: Cursors must be declared before they can be used. The declaration typically involves specifying the query or result set that the cursor will be based on.
  2. Opening: After declaration, the cursor needs to be opened to establish a connection with the result set. This step makes the cursor ready for fetching or modifying data.
  3. Fetching: Cursors provide methods to retrieve data from the result set row by row. You can use the fetch operation to move the cursor to the next row and access the data contained within it.
  4. Updating: In addition to retrieving data, cursors often allow you to update or modify the data in the current row. This can be useful when you need to make changes to specific records in a result set.

Cursor API Function Reference

Cursor Cleanup Functions Cleanup API for core cursors.
Row Scan Cursor Association Functions Core cursor association API for retrieving rows in rowid order positioned at a given row.
Key Scan Cursor Association Functions Core cursor association API for retrieving rows in key order positioned at a given row.
Set Scan Cursor Association Functions Core cursor association API for retrieving rows in a set.
Other Cursor Association Functions Core cursor association API for other functions.
Cursor Navigation Functions API for navigating a core cursor.
Read Functions API for reading data from a row identified by a core cursor.
Update Functions API for updating data for a row identified by a core cursor.
Delete Functions API for deleting a row identified by a core cursor.
Set Functions API for modifying set relationships for core cursors.
Cursor Comparison Functions API for comparing core cursor positions.

Cursor Operations

All of the data contained in a RaimaDB database is accessed through use of the cursors. Thus, a thorough understanding of the use of these cursors is necessary.

The retrieval or update of RaimaDB data is always a two-step process. First the location of the data is established, and then the data is read or updated. The located data is always in the form of a cursor which is associated with the row to be retrieved or updated.

Cursor Navigation

Database cursor navigation refers to the process of traversing or moving through the result set of a database query using a cursor. A cursor is a database object that enables programmatic access to the rows returned by a query. It allows you to retrieve and manipulate data row by row.

Cursor navigation involves several key operations:

  1. Opening the cursor: The first step is to open the cursor, which establishes a connection between the database and the result set of the query. This prepares the cursor to fetch rows.
  2. Fetching rows: Once the cursor is opened, you can fetch rows from the result set one at a time. The fetch operation retrieves the current row and moves the cursor to the next row in the result set. You can repeat the fetch operation until you reach the end of the result set.
  3. Navigating the cursor: Cursor navigation includes moving the cursor in various ways. For example, you can move the before the first row, cursor to the first row, last row, next row, previous row, after the last row, or a specific row based on certain conditions or positions within the result set.
  4. Processing rows: After fetching a row, you can process the data retrieved from that row. It may involve performing calculations, applying business logic, updating or deleting data, or simply displaying the row's information.