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 |
How to create DSN..Explain?
2 Answers Accenture, BeBo Technologies, Infosys,
how table is defined in plsql table? how can i select column from plsql table? can i use select * from plsql table type?
How do I limit the number of rows returned by an oracle query after ordering?
What is set verify off in oracle?
24. Display the order number for all orders whose average item cost is greater than the overall average item cost across all orders.
Difference between primary key and unique key ?
77 Answers Accenture, B2B Software Technologies, Cognizant, HP Finsoft, IndiaNIC, Karomi Technology, Keane India Ltd, L&T, Onward eServices, R Systems, Shakti, Techtic Solutions,
What is sharded cluster?
how to clone 9i Database on to 10g Database.
What is materialized view in Oracle?
hi friends i completed b.com 2004.i have 3y accounting exp. in manufacturing company.now i have completed oracle finance.pls suggest me how will get job in oracle.can i get job in oracle.
How do we display rows from the table without duplicates?
What are the differences between date and timestamp in oracle?