--20010986.160

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN OLDSPECIFICAMOUNT CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN STARTDATE CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN NEWSPECIFICPERCENTAGE CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN OLDSPECIFICPERCENTAGE CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN NEWSPECIFICAMOUNT CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN OVERRULED CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN MINIMUMAMOUNT CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN MAXIMUMAMOUNT CASCADE CONSTRAINTS;

/* after deleting columns, the order of the columns is not ABS standard Reorganized the table and updated the fields using backup table */

-- commented out the columns order change to prevent performance issues
/* CREATE TABLE CUSTOMERSPECIALCHARGE_BKK AS (SELECT * FROM CUSTOMERSPECIALCHARGE);

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN TIMESTAMP CASCADE CONSTRAINTS;

ALTER TABLE CUSTOMERSPECIALCHARGE
  DROP COLUMN SYSTEMUSER_ID CASCADE CONSTRAINTS;
  
ALTER TABLE CUSTOMERSPECIALCHARGE
	ADD (SYSTEMUSER_ID NUMBER NULL);
  
ALTER TABLE CUSTOMERSPECIALCHARGE
	ADD (TIMESTAMP DATE NULL);
 
UPDATE CUSTOMERSPECIALCHARGE C
     SET C.SYSTEMUSER_ID=
         (SELECT CK.SYSTEMUSER_ID
            FROM CUSTOMERSPECIALCHARGE_BKK CK
           WHERE C.CUSTOMER_ID = CK.CUSTOMER_ID 
             and C.SPECIALCHARGE_ID = CK.SPECIALCHARGE_ID);
COMMIT;
             
   UPDATE CUSTOMERSPECIALCHARGE C
     SET C.TIMESTAMP =
         (SELECT CK.TIMESTAMP
            FROM CUSTOMERSPECIALCHARGE_BKK CK
           WHERE C.CUSTOMER_ID  = CK.CUSTOMER_ID 
             AND C.SPECIALCHARGE_ID = CK.SPECIALCHARGE_ID);
COMMIT;
             
ALTER TABLE CUSTOMERSPECIALCHARGE
	MODIFY (SYSTEMUSER_ID NUMBER  NOT NULL);
  
ALTER TABLE CUSTOMERSPECIALCHARGE
	MODIFY (TIMESTAMP DATE NOT NULL);
  
DROP TABLE CUSTOMERSPECIALCHARGE_BKK; */


