Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: [PMX:#] update about 100K records

RE: [PMX:#] update about 100K records

From: Jamadagni, Rajendra <Rajendra.Jamadagni_at_espn.com>
Date: Wed, 09 Jul 2003 05:46:01 -0700
Message-ID: <F001.005C4104.20030709053924@fatcity.com>

How about creating a function based index on the column ...

function my_func(table_column in number) return number is
begin
  if table_column = <your_current_value> then

     return 1

  else

     return null;
  end if;

end my_func;
/

Then use this function to create a FBI on the table (pk_column, my_func(table_column)
/

This will give you only those 100000 rows. Then write an update statement that will use the FBI in the where clause and you are done.

After words drop the fbi.

Raj



Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art !

-----Original Message-----
From: Maryann Atkinson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 08, 2003 7:09 PM
To: Multiple recipients of list ORACLE-L Subject: [PMX:#] update about 100K records

I have a table of about one million records.

About 100,000  of them have a flag which I need it set to 0.

Because of the size of the rollback segment, I cannot update them all and then commit, I need to do it in sets of 1000 records.

Do I need a cursor for this?

I had something like that:
DECLARE
      I  BINARY_INTEGER;

Cursor  MyCursor  IS
         SELECT   *
         FROM     (Table_Name)
         WHERE    (Condition)
         FOR UPDATE;


BEGIN

      I := 0;
      FOR MyRec IN MyCursor LOOP
            UPDATE (Table_name)

          SET   delete_flag = 1
          WHERE         CURRENT OF MyCursor;
            I := I + 1;
            IF MOD(I, 1000) = 0 THEN
                COMMIT;
            END IF;


     END LOOP;
END;
/

But "FOR UPDATE" does not really work well, and at the 1000th record when it reaches the commit, its dropping out of the loop.

Can I use ROWNUM to update them in batches of 1000 per time?

Thanks,
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). ********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************2
Received on Wed Jul 09 2003 - 07:46:01 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US