How do I get rid of duplicate data when Oracle BULK INSERT ____oracle

Source: Internet
Author: User
Tags bulk insert oracle database

Use the storage process to bulk extract a view of the data, inserted into a new table, the view data 240 million, yesterday to 60 million on the card, do not know what the reason, want to continue to execute this stored procedure, want to ask what conditions to avoid inserting those have been inserted in the data

Unique field on view XH

The storage process is as follows

Create or replace procedure up_table as

Type A is table of new_table%rowtype;

In_data A;

I number;

Cursor C is select * from Fcd_ci_gps@dblink;

Begin

Open C;

Loop

Fetch c Bulk collect into in_data limit 5000;

ForAll I in 1..in_data.count

INSERT into new_table values In_data (i);

Commit

Exit when in_data.count=0;

End Loop;

Close C;
End







Recently made a similar demand you said:

My business needs are,
Get the data from the Oracle database and synchronize to SQL Server.

The first is to configure the connection settings between the two databases.
I'm SQL Server. Connect Oracle Configure SQL Server's link servers ok.

The following are the contents of the stored procedure:

1. Create a temporary table.

INSERT into temporary table Select Remote table via remote connection.
Get the data first to local,.

Then use the data from the temp table to compare it to your local business table.
The query does not pass the data.
Java Code   --  (1)   remote read NC requirement plan, after grouping data, insert to temporary table   #tmp_pl_plan中.        set  @InsertStrSQL  =  @InsertStrSQL +  @tmpStrSQl;        print (@InsertStrSQL)  ;       exec (@ Insertstrsql);              select  @tmpCont  = count (1)  from  #tmp_pl_plan  ;               -- state:0 new, 1 modified, 2 delete        --  (2)   data in local data and temporary tables, To update the number of schedules in the local table that are not equal to the temporary table .                      update t set t.plnum  = a.plnum , t.state = 1           from   #tmp_pl_plan  a,NC_PL_PLAN t            where a.factorycode = t.factorycode and  a.weldingdate = t.weldingdate           and  a.divisions = t.divisions and a.zzmadeline = t.zzmadeline            and a.zzweldingwayCode  =  t.zzweldingwaycode and a.zzmadelinetypecode = t.zzmadelinetypecode            and a.convertedcode = t.convertedcode and   a.ncfprocode = t.ncfprocode              and t.plnum != a.plnum              and t.weldingdate >=   @fbegdate  and t.weldingdate <=  @fenddate                --  (3)   Compare data to find records in a local table that do not exist in a temporary table, and then modify the number in the local table =0 ,state  = 3  Express Delete            update t set  t.plnum = 0 ,t.state = 2              from NC_PL_PLAN t           where  t.weldingdate between   @fbegdate  and  @fenddate              and not exists  (                select 1 from   #tmp_pl_plan  a where  a.factorycode = t.factorycode and a.weldingdate = t.weldingdate                and a.divisions =  t.divisions and a.zzmadeline = t.zzmadeline                 and a.zzweldingwayCode  = t.zzweldingwayCode and  a.zzmadelinetypecode = t.zzmadelinetypecode                and a.convertedcode = t.convertedcode  and  a.ncfprocode = t.ncfprocode                           );                  --  (4)   contrast data, adding data in temporary tables that do not exist in the current table         --delete    NC_PL_PLAN;       insert into  NC_PL_PLAN        select * from  #tmp_pl_plan  t        where t.weldingdate between   @fbegdate  and  @fenddate         and not exists  (            select 1 from   NC_PL_PLAN a where a.factorycode =  t.factorycode and a.weldingdate = t.weldingdate            and a.divisions = t.divisions and a.zzmadeline =  t.zzmadeline            and a.zzweldingwaycode   = t.zzweldingwaycode and a.zzmadelinetypecode = t.zzmadelinetypecode            and a.convertedcode =  t.convertedcode and a.ncfprocode = t.ncfprocode            and a.weldingdate >=   @fbegdate  and a.weldingdate<=  @fenddate          )        order by t.weldingdate desc ;  

Recently made a similar demand you said:

My business needs are,
Get the data from the Oracle database and synchronize to SQL Server.

The first is to configure the connection settings between the two databases.
I'm SQL Server. Connect Oracle Configure SQL Server's link servers ok.

The following are the contents of the stored procedure:

1. Create a temporary table.

INSERT into temporary table Select Remote table via remote connection.
Get the data first to local,.

Then use the data from the temp table to compare it to your local business table.
The query does not pass the data.
Java Code   --  (1)   remote read NC requirement plan, after grouping data, insert to temporary table   #tmp_pl_plan中.        set  @InsertStrSQL  =  @InsertStrSQL +  @tmpStrSQl;        print (@InsertStrSQL)  ;       exec (@ Insertstrsql);              select  @tmpCont  = count (1)  from  #tmp_pl_plan  ;               -- state:0 new, 1 modified, 2 delete        --  (2)   data in local data and temporary tables, To update the number of schedules in the local table that are not equal to the temporary table .                      update t set t.plnum  = a.plnum , t.state = 1           from   #tmp_pl_plan  a,NC_PL_PLAN t            where a.factorycode = t.factorycode and  a.weldingdate = t.weldingdate           and  a.divisions = t.divisions and a.zzmadeline = t.zzmadeline            and a.zzweldingwayCode  =  t.zzweldingwaycode and a.zzmadelinetypecode = t.zzmadelinetypecode            and a.convertedcode = t.convertedcode and   a.ncfprocode = t.ncfprocode              and t.plnum != a.plnum              and t.weldingdate >=   @fbegdate  and t.weldingdate <=  @fenddate                --  (3)   Compare data to find records in a local table that do not exist in a temporary table, and then modify the number in the local table =0 ,state  = 3  Express Delete            update t set  t.plnum = 0 ,t.state = 2              from NC_PL_PLAN t           where  t.weldingdate between   @fbegdate  and  @fenddate              and not exists  (                select 1 from   #tmp_pl_plan  a where  a.factorycode = t.factorycode and a.weldingdate = t.weldingdate                and a.divisions =  t.divisions and a.zzmadeline = t.zzmadeline                 and a.zzweldingwayCode  = t.zzweldingwayCode and  a.zzmadelinetypecode = t.zzmadelinetypecode                and a.convertedcode = t.convertedcode  and  a.ncfprocode = t.ncfprocode      &

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.