Define the cursor lock types

Define the cursor lock types.

- Cursors allow row-by-row processing of the resultsets.

- It is a database object which is used to retrieve data from a resultset one row at a time.

Following are the three lock types of cursor:

1. READ ONLY
2. SCROLL LOCK
3. OPTIMISTIC

- Each time you fetch a row from the cursor, it results in a network roundtrip.

- Cursors are also costly because they require more resources and temporary storage.

1. READ ONLY:
- It prevents any updates to the table.

2. SCROLL LOCK:
- It allows you to make changes to the table.

3. OPTIMISTIC:
- It checks if any changes in the table record since the rows are fetched before updating.
- If there is no change, then the cursor can update.
Cursor optimization tips
Close cursor when it is not required. You shouldn’t forget to deallocate cursor after closing it........
Disadvantages/limitation of the cursor
Cursor requires a network roundtrip each time it fetches a record, thus consume network resources........
Define scrollable cursor
You can use keyword SCROLL to make cursor Scrollable.......
Post your comment