Andrea,

try the following thur SqlPlus:

set serveroutput on
declare

cursor c1 is
    select b.site_id,c.area_code
       from site_location b, area c
       where c.area_id = b.area_id;

rec_count number := 0;
begin

  for c1_rec in c1 loop
    update site
      site_code = c1_rec.area_code
       where site.site_id = c1_rec.site_id;
    rec_count := rec_count + 1;
    if rec_count > 5000 then
       commit;
       dbms_output.put_line('Commiting');
       rec_count := 1;
    end if;
  end loop;
  commit;
  dbms_output.put_line('Final Commiting');
end;
/

hope this helps!

Tom Mercadante
Oracle Certified Professional


-----Original Message-----
Sent: Thursday, November 15, 2001 3:00 PM
To: Multiple recipients of list ORACLE-L


Hi all,

Thank you all those for responding to the frequent
commit question.  So members suggested using count,
and loop.  May I have real example.  (OK, I'm bad at
pl/sql).  Site table has 2 million rows, how to so a
commit, let's say 5000 rows.  Site_id is unique in
site table.  How does the counter fit in the following
update sql?

update site a set a.site_code =
       (select c.area_code
       from site_location b,
       area c where a.site_id = b.site_id and
c.area_id = b.area_id);

I put a counter is a sample code, and update runs 10
times! then commit, then runs another 10 times! then
commit ....  I must miss something.  Please give me as
mush detail as you can.  Thank you so much!



Andrea

__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Andrea Oracle
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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.com
-- 
Author: Mercadante, Thomas F
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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