----Script made by Paul for BNL - it can be run for all customers
-- New speed index



begin
execute immediate('create index XSPEEDWORKORDER on WORKORDER (customer_link_id, trunc(completiondate), origin, status_id);');
exception when others then null;
end;
/


-- adjust index 

begin
execute immediate('drop index XIE4STATUSQUOHEADER;');
exception when others then null;
end;
/

begin
execute immediate('
create index XIE4STATUSQUOHEADER on STATUSQUOHEADER (statusquodate, statusquotype, subtype, invoicebusinessunit_id)
  tablespace INDX
  storage
  (maxextents unlimited );');
exception when others then null;
end;
/

---drop index
begin
execute immediate('drop index XIF2SQITEMINCIRCULATION;');
exception when others then null;
end;
/

--adjust index  
begin
execute immediate('drop index XIF1SQITEMINCIRCULATION;');
exception when others then null;
end;
/

begin
execute immediate('create index XIF1SQITEMINCIRCULATION on SQITEMINCIRCULATION (STATUSQUOHEADER_ID, CUSTOMER_LINK_ID, DISTRIBUTIONPOINT_LINK_ID)
  tablespace INDX
  storage
  (maxextents unlimited); ');
exception when others then null;
end;
/
  
  
-- Create/Recreate indexes 
begin
execute immediate('create index XSPEEDSQMATINCIRCULATION on SQMATINCIRCULATION (statusquoheader_id, customer_link_id, distributionpoint_link_id);');
exception when others then null;
end;
/


