Updating two different tables with cursor oracle

p_col_names
updating two different tables with cursor oracle-8updating two different tables with cursor oracle-19

But, before invoking the procedure, you need to define the variables appropriately.

The FOR UPDATE OF clause helps us in locking up the intended table rather all available tables.

In the below example, the cursor CUR is associated with a SELECT statement having the tables EMPLOYEES and joined in its FROM clause. EMPLOYEE_ID clause in the below snippet locks up only rows of the EMPLOYEES table, thus making the DEPARTMENTS table available for modification to the other session users. For this, the cursor CUR is associated with a SELECT statement joining the EMPLOYEES and the DEPARTMENTS tables with a FOR UPDATE OF clause on the employee ID.

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

Once we open a cursor having a FOR UPDATE clause, all the rows returned by the SELECT statement are locked for our changes until a commit or a rollback is placed to release the lock.

Leave a Reply