Answer Posted / tvgiriprasad
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 |
Post New Answer View All Answers
Will you be able to store pictures in the database?explain.
How to manage transaction isolation level?
What is the parameter mode that can be passed to a procedure?
 How to use an oracle sequence generator in a mapping?
Difference between inner join vs where ?
What are data pump export and import modes?
What are nested tables?
What is meant by recursive hints in oracle?
What privilege is needed for a user to delete rows from tables in another schema?
What are the varoius components of physical database structure of oracle database?
How do I use unicode codesets with the weblogic jdriver for oracle driver?
what are the default admin accounts in Oracle 10g ?
How to start an oracle instance?
How can you merge two tables in oracle?
normally database take to refresh time 2 hours. but client asked iwant to refresh with in 5 min that same database. do you have any option in BO and Oracle? explain me briefly...kavi