Question on update ... where current of ...

  • From: Guang Mei <GMei@xxxxxx>
  • To: "'oracle-l@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 17 Mar 2005 23:29:09 -0500

Hi,

A quick pl/sql question for oracle 9i. I have these two pl/sql blocks below,
does oracle treat them same internally when inside the loop? 

Would "method 2" be better, in terms of performance?

Thanks.

Guang
 
-- method 1:
DECLARE
 CURSOR c1 IS
        SELECT ID, s1
        FROM t1
        WHERE s1 = 'abc';
        FOR UPDATE;
BEGIN
        FOR x IN c1 LOOP
            UPDATE t1 
            SET StateID = 'NEW',
                LASTMODIFIEDDT = sysdate 
            WHERE s1 = x.s1;
        END LOOP;
END;


-- method 2:
DECLARE
 CURSOR c1 IS
        SELECT ID, s1
        FROM t1
        WHERE s1 = 'abc';
        FOR UPDATE;
BEGIN
        FOR x IN c1 LOOP
            UPDATE t1 
            SET StateID = 'NEW',
                LASTMODIFIEDDT = sysdate 
            where current of c1;
        END LOOP;
END;
************************************************************************* 
PRIVILEGED AND CONFIDENTIAL: 
This communication, including attachments, is for the exclusive use of
addressee and may contain proprietary, confidential and/or privileged
information.  If you are not the intended recipient, any use, copying,
disclosure, dissemination or distribution is strictly prohibited.  If you
are not the intended recipient, please notify the sender immediately by
return e-mail, delete this communication and destroy all copies.  
*************************************************************************
--
//www.freelists.org/webpage/oracle-l

Other related posts: