Yes, using WHERE CURRENT OF is faster. It is the same as saying "WHERE rowid
= emprec.rowid", just more readable. And accesses by rowid are faster than
index accesses.

Also, what happens if you don't have a unique or primary constraint on the
table and whole rows can be duplicated? Then you pretty much need to use
WHERE CURRENT OF.

HTH
Kevin

-----Original Message-----
Sent: Friday, July 11, 2003 2:54 PM
To: Multiple recipients of list ORACLE-L


Could anyone give us an idea as to the full usefullness
of CURRENT OF?  Here are my two separate examples:


/*   1  this one has a CURRENT OF  */

DECLARE

    CURSOR  EmpCursor  IS
            SELECT  *
            FROM    Emp
            FOR     UPDATE;

BEGIN
     FOR EmpRec IN EmpCursor LOOP

         UPDATE EMP
         SET    SALARY = SALARY * 1.08
         WHERE  CURRENT OF EmpCursor

     END LOOP;

END;


/*   2 same as above, except without the CURRENT OF   */
DECLARE

   CURSOR  EmpCursor  IS
           SELECT  *
           FROM    Emp
           FOR     UPDATE;

BEGIN
     FOR EmpRec IN EmpCursor LOOP

         UPDATE EMP
         SET    SALARY = SALARY * 1.08
         WHERE  EMP_ID = EmpRec.Emp_ID;

     END LOOP;

END;
/


Is one more efficient than the other? If I could have done
business without the CURRENT OF, then why did oracle made
it available?

thx
maa 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Maryann Atkinson
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Kevin Toepke
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to