-- ABS-118825 Add creation user in client table / ABS-127159

ALTER TABLE CLIENT 
ADD (CREATIONUSER_ID NUMBER DEFAULT 0 NOT NULL,
     CREATIONTIMESTAMP DATE DEFAULT SYSDATE NOT NULL);

UPDATE CLIENT C SET 
       C.CREATIONUSER_ID = (SELECT NVL((SELECT CL.SYSTEMUSER_ID FROM CLIENT_LINK CL WHERE CL.CLIENT_ID = C.CLIENT_ID), 0) FROM DUAL) ,
       C.CREATIONTIMESTAMP = (SELECT NVL((SELECT CL.TIMESTAMP FROM CLIENT_LINK CL WHERE CL.CLIENT_ID = C.CLIENT_ID), sysdate) FROM DUAL);
       
COMMIT;
