What WHERE CURRENT OF clause does in a cursor?
Answers were Sorted based on User's Feedback
If you want to UPDATE or DELETE record from table by using cursor which is defined from same table,"WHERE CURRENT OF" clause can be used. We have to create cursor with "FOR UPDATE" clause to use above clause.
The most recent record fetched from the table (by looping of cursor records) should be updated or deleted by using "WHERE CURRENT OF". When a cursor open with FOR UPDATE clause ,cursor's active set will have row level Exclusive Lock. Other sessions can query the table records, and not able to delete/update or SELECT with FOR UPDATE clause.
Example: Want to update value for GRADE column to '1' for the student who has Id = '1'.
Declare
cursor C1 is
select st_id, grade,st_last_name from student where st_id = 3;
for update of grade;
[ variable declaration ……] ;
begin
open C1;
fetch C1 into v_id,v_grade,v_name;
if C1%notfound then
dbms_output.put_line (‘No Record is found.’);
else
update student set grade=1 WHERE CURRENT OF;
COMMIT;
END IF;
CLOSE C1;
end;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / kamala k n
return latest fetch row to perform DML on it it is unique
| Is This Answer Correct ? | 0 Yes | 0 No |
Can we convert a date to char in oracle and if so, what would be the syntax?
How to connect the oracle server as sysdba?
How to estimate disk space needed for an export job?
How to use attributes of the implicit cursor in oracle?
How to display employee records who gets more salary than the average salary in the department?
What is the difference between sharding and replication?
Why do I get unexpected characters from 8-bit character sets in weblogic jdriver for oracle?
What is a proxy class?
You have found corruption in a tablespace that contains static tables that are part of a database that is in NOARCHIVE log mode. How would you restore the tablespace without losing new data in the other tablespaces?
HI Friends Myself Manoj,i am from bengaluru.i have 1 yr of exp in PLSQL but not upto the mark..now attending interviews but m not able to clear even 1 round..i have attended 3 interviews till today.purpose of writing this query is,i want to know the intreview topics that interviewer going to ask frequently,mainly SCENARIO based questions.IF anybody have any PLSQL projects please give it to me,it will helps me alot.Thanks for your patience.
Whether Oracle satisfy more codd rules or db2 satisfy more codd rules? How meny of each can satisfy ? Please answer me. Advance thanks
According to oracle specification VIEW is a object. OBJECT that means anything stored in the oracle database that has the physical existence.why VIEW doesn't take memory in oracle database, but it is treated as a object ?Please explain ?