--Order 20014744.330

ALTER TABLE MOBILEDEVICE
  ADD (BUSINESSUNIT_ID NUMBER  NULL);

ALTER TABLE MOBILEDEVICE
ADD CONSTRAINT MOBILEDEVICE_BUSINESSUNIT FOREIGN KEY (BUSINESSUNIT_ID) REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);

UPDATE MOBILEDEVICE MD
SET MD.BUSINESSUNIT_ID = (SELECT MIN(BU.BUSINESSUNIT_ID)
   FROM BUSINESSUNIT BU, PLANT P
  WHERE MD.PLANT_ID = P.PLANT_ID
    AND P.PLANT_ID = BU.PLANT_ID);

COMMIT;

ALTER TABLE MOBILEDEVICE
  MODIFY (BUSINESSUNIT_ID NUMBER  NOT NULL);

