INSENSITIVE
INSENSITIVE is a keyword used in SQL databases to define a cursor that makes a temporary copy of the data selected, allowing it to retain the same select result set even if the underlying data is modified. It therefore ensures a stable set of results for all fetches of the cursor, regardless of changes being made to rows by the database or by other users.
Example
Output
Explanation
In this example, the keyword INSENSITIVE
is used while declaring a cursor. It is used to create a temporary copy of the data retrieved by the cursor so that changes made to the database data cannot affect the cursor results. The query within the cursor is fetching the customerName
from the Customers
table.
Example
Output
Explanation
Here, an INSENSITIVE cursor is utilized to retrieve every order from the Orders table. The data is fetched from the cursor using a WHILE loop. The key aspect is that this INSENSITIVE cursor displays the data as it was when the cursor opened, meaning modifications to the table during the cursor’s lifetime are not reflected in the data presented by the cursor.