Massive Update commit every 1000 records

From: Roger Xu <wellmetus_at_gmail.com>
Date: Fri, 13 Nov 2009 13:50:05 -0600
Message-ID: <eb64345d0911131150n332f87d2m242771eab05f1ca6_at_mail.gmail.com>



*Hi List,*
**
*Background:* 9i (9.2.0.8.0) HP-UX B.11.31 U ia64
  • *
    *We need to shrink SSN to the last 4 digit.*
  • *
    *update sales set ssn=to_number(substr(to_char(ssn),-4));*
    **
    *But the sales table is quite large and we want to commit every 1000
    records.*
  • *
    *Does anyone have a better idea to do this rather than below?*
  • *
    *Thanks,*
  • *
    *Roger*

declare
  cursor c12 is select ssn from sales for update of ssn;   n number := 0;
begin

   for eachc12 in c12 loop
    if eachc12.ssn is not null then

      n := n + 1;
      update sales set ssn=to_number(substr(to_char(ssn),-4)) where current
of c12;
      if ( n = 1000 )
      then
         commit;
      end if;

  end if;
  end loop;
  commit;
end;
--
http://www.freelists.org/webpage/oracle-l
Received on Fri Nov 13 2009 - 13:50:05 CST

Original text of this message