GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  Basics
Go To First  |  Previous Question  |  Next Question 
 Basics  |  Question 35 of 49    Print  
Why do we need to use 'WHERE CURRENT OF' clause

  
Total Answers and Comments: 3 Last Update: June 24, 2008     Asked by: ramahesh 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: shamkohli
 
While using cusor in PL/SQL, when we update a record, we can write
WHERE CURRENT OF     along with cursor_name.
This is done in place of the where condition while updating. If we give WHERE condition, the whole table have to be searched for the condition to be fulfilled for the updation to be done. But if we write 'WHERE CURRENT OF' the updation is done in the current record of the table without scanning the whole table.

Above answer was rated as good by the following members:
saginandkishore, subajay, ds_devi
May 04, 2007 01:28:35   #1  
panda_dilip Member Since: May 2007   Contribution: 1    

RE: Why do we need to use 'WHERE CURRENT OF' clause
This is generally used where we use cursor in a PL/SQL block.
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 2Overall Rating: -2    
June 17, 2008 05:16:15   #2  
shamkohli Member Since: June 2008   Contribution: 6    

RE: Why do we need to use 'WHERE CURRENT OF' clause
While using cusor in PL/SQL when we update a record we can write
WHERE CURRENT OF along with cursor_name.
This is done in place of the where condition while updating. If we give WHERE condition the whole table have to be searched for the condition to be fulfilled for the updation to be done. But if we write 'WHERE CURRENT OF' the updation is done in the current record of the table without scanning the whole table.

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
June 24, 2008 19:57:23   #3  
saginandkishore Member Since: June 2008   Contribution: 5    

RE: Why do we need to use 'WHERE CURRENT OF' clause
Where current of is used for updating the data referenced by cursor which was created as "SELECT FOR UPDATE".

DECLARE
CURSROR MY_CURR IS
SELECT COL1 COL2 COL3 ... COLN
FROM TABLE_NAME
WHERE COND1 AND COND2
FOR UPDATE OF COLX;
......
BEGIN
....
UPDATE TABLE_NAME SET COLX <NEW_VALUE> USING CURRENT OF MY_CURR;
.....
END;

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape