Start Updating a record using cursor

Updating a record using cursor

In these type of situations it is ideal to use a Update Cursor, than using the default read only one.

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.

The latest version of this topic can be found at Recordset: Adding, Updating, and Deleting Records (ODBC). For more information about how updates are carried out and how your updates appear to other users, see Recordset: How Recordsets Update Records (ODBC).

Here are the answers to the PL/SQL Challenge questions in last issue’s “Error Management” article: Answer 1: Choices (a), (c), and (d) all raise ORA-00001, also known as DUP_VAL_ON_INDEX inside PL/SQL code.

However if you really have to use a cursor to do an update then you should mark it as insensitive: I haven't confirmed this on 2008 but certainly on 2005 and below, you can expect all kinds of weirdness if you update the data your cursor is defined against, without marking the cursor as insensitive.

There can be a situation where you have to use a cursor, even though the experts say not to use cursors or to avoid them as much as possible.

But if you look closely, most of the time we use cursors to iterate through a row collection and update the same table.

It’s rare, in fact, that the data with which you are working is just a single value, so records and other composite datatypes are likely to figure prominently in your PL/SQL programs.