--order 502356(from PVD)
begin
execute immediate ('alter table BUSINESSUNIT
  add constraint XUNIQUEBUCODE unique (CODE)');
exception
	when others then null;
end;
/

alter table I_CUSTOMER
  add constraint I_FK_CUSTOMER_BUCODE foreign key (BUSINESSUNIT)
  references businessunit (CODE);

-- Drop check constraints 
alter table I_CUSTOMER
  drop constraint I_CUST_YN_SPLITINVOICESPERACT;


-- Add/modify columns 
alter table I_CUSTOMER drop column SPLITINVOICESPERACTIVITY;
alter table I_CUSTOMER add SPLITINVOICES number default 0  not null;

-- Create/Recreate check constraints 
alter table I_CUSTOMER
  add constraint I_CUST_SPLITINVOICESPERACT
  check (SPLITINVOICES IN (0,1,2,3));

-- Add comments to the columns 
comment on column I_CUSTOMER.SPLITINVOICES
  is 'Possible values:
0=No Split up
1=Per product grouping code
2=Per cost center
3=Rent / other services';


alter table I_CUSTOMER add ROUTEDESCRIPTION varchar2(200);
