------------ ERP_I_PLPC_BM6 ------------
CREATE TABLE ERP_I_PLPC_BM6
( TRANSFER_ID           NUMBER NOT NULL,
  TRANSFER_STATUS       NUMBER DEFAULT 0 NOT NULL,
  WEEKLYUSAGE           NUMBER NOT NULL,
  SRCPERCENTAGE         NUMBER NOT NULL,
  CALCULATION           NUMBER NOT NULL,
  TIMESTAMP             DATE   DEFAULT SYSDATE NOT NULL);

COMMENT ON COLUMN ERP_I_PLPC_BM6.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
  
COMMENT ON COLUMN ERP_I_PLPC_BM6.CALCULATION
  IS '0 = Split qually, 1 = Front loaded, 2 = Back loaded';
  
ALTER TABLE ERP_I_PLPC_BM6
  ADD CONSTRAINT XPKERP_I_PLPC_BM6 PRIMARY KEY (TRANSFER_ID);

CREATE INDEX XIE1ERP_I_PLPC_BM6 ON ERP_I_PLPC_BM6 (TRANSFER_STATUS);

ALTER TABLE ERP_I_PLPC_BM6 ADD CONSTRAINT CHK_ERP_I_PLPC_BM6_CALCULATION CHECK (CALCULATION IN (0,1,2));

ALTER TABLE ERP_I_PLPC_BM6
  ADD CONSTRAINT FK_ERP_I_PLPC_BM6_ERP_I_PLPC FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_I_PRODUCTLISTPERCUSTOMER (TRANSFER_ID) ON DELETE CASCADE;

ALTER TABLE ERP_I_PLPC_BM6
  ADD CONSTRAINT CHK_ERP_I_PLPC_BM6_TRANSFERSTATUS
  CHECK (TRANSFER_STATUS IN (-1,0,1));
