
ALTER TABLE LEAVES ADD ALLOW_ADV_LEAVE CHAR(1);

UPDATE LEAVES SET ALLOW_ADV_LEAVE = CASE WHEN BAL_OPT = 'Y' THEN 'Y' ELSE 'N' END WHERE ALLOW_ADV_LEAVE IS NULL ;
COMMIT;

ALTER TABLE LVETABLE ADD ALLOW_ADV_LEAVE CHAR(1);
UPDATE LVETABLE SET ALLOW_ADV_LEAVE = (SELECT CASE WHEN BAL_OPT = 'Y' THEN 'Y' ELSE 'N' END FROM 
	LEAVES WHERE LEAVES.LVE_CODE = LVETABLE.LVE_CODE)
WHERE ALLOW_ADV_LEAVE IS NULL ;
COMMIT;

INSERT INTO OBJ_ITEMCHANGE (OBJ_NAME,FORM_NO,FIELD_NAME,MANDATORY) VALUES ('leave','1','bal_opt',null);
COMMIT;

