Pl sql updating current record in cursor

Oracle also determines an execution plan, associates host variables and cursor parameters with the placeholders in the SQL statement, determines the result set, and sets the cursor to the first row in the result set.

More about parameterized cursor in the next tutorial.

When you open a cursor, Oracle parses the query, binds variables, and executes the associated SQL statement.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.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.In this scenario, the cursor result set can be limited using the traditional When we associate a SELECT statement with more than one table joined together to a cursor with a FOR UPDATE clause, we end up locking all the tables in the FROM clause of the SELECT statement, where we just need to lock a single table for our purpose.

Leave a Reply