Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

batch update statement

OraCSep 8 2020 — edited Sep 11 2020

Hi,

I have 2 tables:

create table TABLE1

(

   CI_ID NUMBER(20,0)         not null,

   SPID NUMBER(20,0)         not null,

   C_DTM          TIMESTAMP            not null

)

create table TABLE2

(

   CIDES_ID    NUMBER(20,0)         not null,

   CI_ID NUMBER(20,0)         not null,

   SPID NUMBER(20,0),

   C_DTM          TIMESTAMP

)

30 days ago I added SPID and C_DTM to TABLE2 and now I need to populate them from the values in TABLE1

So far I've got the following but I have millions of rows per day and I want to do them day by day which I can manage for example like I have below for all records older than 29 days, but inside a particular day I want to batch it to update it by 1000 records a time and then commit.

Any suggestions on how I can batch the statement below?

UPDATE TABLE2 CIDES

   SET (C_DTM, SPID) = (SELECT CID.C_DTM, CID.SPID

                         FROM TABLE1 CID

                        WHERE CIDES.CI_ID = CID.CI_ID)

WHERE EXISTS (

    SELECT 1

      FROM TABLE1 CID

     WHERE CIDES.CI_ID = CID.CI_ID

and CID.C_DTM < (sys_extract_utc(current_timestamp) - 20));


Thanks

Comments
Post Details
Added on Sep 8 2020
10 comments
2,668 views