Updating record from cursor oracle expat women dating singapore
The WHERE CURRENT OF clause in an UPDATE or DELETE statement states that the most recent row fetched from the table should be updated or deleted.
We must declare the cursor with the FOR UPDATE clause to use this feature.
Another Example of WHERE CURRENT OF Go through all Maths students and set all GPA’s under 4.0 to 4.0!
DECLARE this Student Student%ROWTYPE; CURSOR Maths_Student IS SELECT * FROM Student WHERE SID IN (SELECT SID FROM Take WHERE CID = ’CS145’) FOR UPDATE; BEGIN OPEN Maths_Student; LOOP FETCH Maths_Student INTO this Student; EXIT WHEN (Maths_Student%NOTFOUND); IF (this Student.
The FOR UPDATE clause in the SELECT statement can only be specified in the top level; subqueries cannot have this clause.
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.
This clause becomes meaningless if we use a single table SELECT clause as the minimum Oracle has provided us with the WHERE CURRENT OF clause for both DELETE and UPDATE statements inside a cursor’s range to make changes to the last fetched row(s) from the cursor with an ease.
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.
The FOR UPDATE OF clause helps us in locking up the intended table rather all available tables.
create table Employee( 2 ID VARCHAR2(4 BYTE) NOT NULL primary key, 3 First_Name VARCHAR2(10 BYTE), 4 Last_Name VARCHAR2(10 BYTE), 5 Start_Date DATE, 6 End_Date DATE, 7 Salary Number(8,2), 8 City VARCHAR2(10 BYTE), 9 Description VARCHAR2(15 BYTE) 10 ) 11 / Table created.