|
I believe (I could be totally wrong here) the reason for the CURRENT OF is both for performance and consistency.
The second example has to run the update statement seperately. CURRENT OF can go directly to the row(s) affected. CURRENT OF still has to modify each block header in the table to lock which is a small performance hit. To prevent that you could update by rowid and avoid the header updates.
Also, the CURRENT OF locks the table so that no one can modify (or even read) it while the transaction is taking place. This guarantees nothing is changing between retrieving values from the cursor and updating the table based on those values.
-----Original Message----- 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). |
- full usefullness of CURRENT OF ??? Maryann Atkinson
- RE: full usefullness of CURRENT OF ??? Chris Stephens
- RE: full usefullness of CURRENT OF ??? Kevin Toepke
- RE: full usefullness of CURRENT OF ??? MaryAnn Atkinson
- RE: full usefullness of CURRENT OF ??? MaryAnn Atkinson
- Re: full usefullness of CURRENT OF ??? Daniel Fink
- RE: full usefullness of CURRENT OF ??? Kevin Toepke
- Re: RE: full usefullness of CURRENT OF ??? rgaffuri
- RE: full usefullness of CURRENT OF ??? Chris Stephens
- full usefullness of CURRENT OF ??? Maryann Atkinson
- Re: full usefullness of CURRENT OF ??? Tanel Poder
- Re: RE: full usefullness of CURRENT OF ??? Jared Still
