Updating record from cursor oracle

Rated 4.3/5 based on 570 customer reviews

This clause can also be extended to lock only the intended table in the SELECT query containing more than one table in joins using the FOR UPDATE OF clause.

updating record from cursor oracle-71

When the Fetch clause is used with a cursor having a FOR UPDATE clause, the PL/SQL unit fails when we try to open the cursor with an ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc. The error description shows that the internal mechanism for the Fetch clause uses either a DISTINCT or a GROUP BY clause which is not permitted alongside the FOR UPDATE clause.

When we want to update or delete the cursor fetched row(s) from the database, we don’t have to form In the below code listing, the employees joined before the year 2000 are archived and during the cursor process, no other session is permitted to make any changes to those employees using the FOR UPDATE clause.

The employee deletion from the transaction table is performed using the WHERE CURRENT OF clause as shown below.

The syntax of using the WHERE CURRENT OF clause in UPDATE and DELETE statements follows: WHERE [CURRENT OF cursor_name | search_condition] The following example opens a cursor for employees and updates the commission, if there is no commission assigned based on the salary level.

The FOR UPDATE clause in the SELECT statement can only be specified in the top level; subqueries cannot have this clause.

Leave a Reply