--- ABS-9026
---------------------------   CLIENTDELIVERYNOTE   --------------------------
ALTER TABLE CLIENTDELIVERYNOTE ADD(STOP_ID NUMBER NULL,
				   ROUTECONTROL_ID NUMBER NULL,
				   ORIGINALDELIVERYDATE DATE NULL);

CREATE INDEX XIF13CLIENTDELIVERYNOTE ON CLIENTDELIVERYNOTE(STOP_ID ASC);

CREATE INDEX XIF14CLIENTDELIVERYNOTE ON CLIENTDELIVERYNOTE(ROUTECONTROL_ID ASC);

ALTER TABLE CLIENTDELIVERYNOTE
ADD CONSTRAINT CLIENTDELIVERYNOTE_STOP_ID FOREIGN KEY (STOP_ID) REFERENCES STOP(STOP_ID) ON DELETE SET NULL;

ALTER TABLE CLIENTDELIVERYNOTE
ADD CONSTRAINT CLIENTDELIVERYNOTE_RC_ID FOREIGN KEY (ROUTECONTROL_ID) REFERENCES ROUTECONTROL(ROUTECONTROL_ID) ON DELETE SET NULL;

update clientdeliverynote c
set c.originaldeliverydate = c.deliverydate;
commit;

ALTER TABLE CLIENTDELIVERYNOTE MODIFY(ORIGINALDELIVERYDATE NOT NULL);


