Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: insert and commit 1000 records at a time
log into target database.
SQL> set long 32000 (or whatever if you have long datatype involved) SQL> set arraysize 100
SQL> set copycommit 1000 <-- LOOKY!!
SQL> COPY FROM ${REMOTE_LOGIN}/${REMOTE_PASSWORD}@${REMOTE_SID} INSERT ${LOCAL_SCHEMA}.${THE_TABLE} USING ${QUERY}; In this case QUERY will probably be "select * from schema_owner.that_other_table". This uses sqlnet, NOT a database link. So the tnsnames.ora that your TNS_ADMIN points to must have an entry for the remote database.
> -----Original Message-----
>
> I have 2 tables, Rqmt and Resource, same structure.
>
> I need to take all almost-one-million records from Rqmt and
> insert them to Resource. So far this worked ok:
>
> DECLARE
> RowCount NUMBER := 0;
>
> BEGIN
> SELECT Count(*)
> INTO RowCount
> FROM RQMT;
>
> IF RowCount > 0 THEN
>
> INSERT INTO RESOURCE
> SELECT Resource_Id, Classification
> FROM RQMT;
>
> RowCount := SQL%RowCount;
>
> DBMS_OUTPUT.PUT_LINE ('TABLE Resource: ' ||
> RowCount || ' Rows
> transitioned.');
> COMMIT;
> ELSE
> DBMS_OUTPUT.PUT_LINE ('TABLE Resource is empty. No data
> transitioned.');
> END IF;
>
> EXCEPTION
> WHEN OTHERS THEN
> Raise;
> END;
> /
>
>
> But now I need to commit every 1000 records. Any suggestions as to
> what would be the best way? I dont think ROWNUM would help here,
> because it would pick the same 1000 records every time, causing
> primary key violation...
>
>
> thx
> maa
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.net
> --
> Author: Maryann Atkinson
> INET: maryann_30_at_yahoo.com
>
> 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: ListGuru_at_fatcity.com (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.net -- Author: Stephen Lee INET: Stephen.Lee_at_DTAG.Com 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: ListGuru_at_fatcity.com (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).Received on Thu Oct 16 2003 - 17:19:32 CDT
![]() |
![]() |