--correct mistake from Script_08.03.04.16.sql

create or replace procedure CORRECTION_PROC is
  V_COUNT number := 0;
begin
  select count(1)
    into V_COUNT
    from USER_CONSTRAINTS
   where UPPER(CONSTRAINT_NAME) = 'PRICETYPE_VALID2'
     and UPPER(TABLE_NAME) = 'COSTPRICELIST';
  if V_COUNT > 0 then
    execute immediate 'ALTER TABLE COSTPRICELIST DROP CONSTRAINT PRICETYPE_VALID2';
  end if;
end CORRECTION_PROC;

execute CORRECTION_PROC; 
DROP procedure CORRECTION_PROC;

ALTER TABLE COSTPRICELISTDETAIL
	ADD CONSTRAINT PriceType_valid2  CHECK (PRICETYPE IN (0, 1, 2));