--Extra FK to BU from I_INVOICEHEADER and I_ARTRANSACTION
--Remark these i-tables will be made empty.

--Delete records in i-tables, so FKs can be placed.
delete from I_INVOICEHEADER;
-- Create new foreign key constraints 
alter table I_INVOICEHEADER
  add constraint FK_I_INVOICEHEADER_BU foreign key (BUSINESSUNIT)
  references businessunit (CODE);

--Delete records in i-tables, so FKs can be placed.
delete from I_ARTRANSACTION;
-- Create new foreign key constraints 
alter table I_ARTRANSACTION
  add constraint FK_I_ARTRANSACTION_BU foreign key (BUSINESSUNIT)
  references businessunit (CODE);
  
--Delete records in i-tables, so FKs can be placed.
delete from I_ACTIVESTOCKLOCATION;
-- Create new foreign key constraints 
alter table I_ACTIVESTOCKLOCATION
  add constraint FK_I_ACTIVESTOCKLOCATION_BU foreign key (BUSINESSUNIT)
  references businessunit (CODE);  

--Delete records in i-tables, so FKs can be placed.
delete from I_CUSTOMERACTIVITIES;
-- Create new foreign key constraints 
alter table I_CUSTOMERACTIVITIES
  add constraint FK_I_ACTIVESTOCKLOC_PROC_BU foreign key (PROCESSBUSINESSUNITCODE)
  references BUSINESSUNIT (CODE);
alter table I_CUSTOMERACTIVITIES
  add constraint FK_I_ACTIVESTOCKLOC_INV_BU foreign key (INVOICEBUSINESSUNITCODE)
  references BUSINESSUNIT (CODE);

--Delete records in i-tables, so FKs can be placed.
delete from I_DELIVERYHISTORY;
-- Create new foreign key constraints 
alter table I_DELIVERYHISTORY
  add constraint FK_I_DELIVERYHISTORY_BU foreign key (BUSINESSUNITNUMBER)
  references businessunit (CODE); 

--Delete records in i-tables, so FKs can be placed.
delete from I_MISCCHARGE;
-- Create new foreign key constraints 
alter table I_MISCCHARGE
  add constraint FK_I_MISCCHARGE_BU foreign key (BUSINESSUNITNUMBER)
  references businessunit (CODE);    

--Delete records in i-tables, so FKs can be placed.
delete from I_SCAN;
-- Create new foreign key constraints 
alter table I_SCAN
  add constraint FK_I_SCAN_BU foreign key (BUSINESSUNIT)
  references businessunit (CODE); 

--Delete records in i-tables, so FKs can be placed.
delete from I_SOILREASONABILITY;
-- Create new foreign key constraints 
alter table I_SOILREASONABILITY
  add constraint FK_I_SOILREASONABILITY_BU foreign key (BUSINESSUNITNUMBER)
  references businessunit (CODE);  

--Delete records in i-tables, so FKs can be placed.
delete from I_SOILTICKET;
-- Create new foreign key constraints 
alter table I_SOILTICKET
  add constraint FK_I_SOILTICKET_BU foreign key (BUSINESSUNITNUMBER)
  references businessunit (CODE);  

--Delete records in i-tables, so FKs can be placed.
delete from I_WORKORDER;
-- Create new foreign key constraints 
alter table I_WORKORDER
  add constraint FK_I_WORKORDER_BU foreign key (BUSINESSUNIT)
  references businessunit (CODE);   
