-- ABS-72373 / ABS-73220
UPDATE DELIVERYSCHEME DS
SET DS.FREQUENCY = 1
WHERE DS.FREQUENCY <=0;
COMMIT;

UPDATE DELIVERYSCHEME DS
SET DS.FREQUENCY = 53
WHERE DS.FREQUENCY > 53;
COMMIT;

ALTER TABLE DELIVERYSCHEME 
	ADD CONSTRAINT FREQUENCY_VALID1 
	CHECK (FREQUENCY BETWEEN 1 AND 53);

UPDATE DELIVERYSCHEME DS
SET DS.OFFSETWEEK = 0
WHERE DS.OFFSETWEEK < 0;
COMMIT;

UPDATE DELIVERYSCHEME DS
SET DS.OFFSETWEEK = DS.FREQUENCY-1
WHERE DS.OFFSETWEEK >= DS.FREQUENCY;
COMMIT;

ALTER TABLE DELIVERYSCHEME
  ADD CONSTRAINT OFFSETWEEK_VALID1
  CHECK (OFFSETWEEK BETWEEN 0 AND FREQUENCY-1);
