-- ABS-76585
---ERP_O_ACCT_MDSE_ROUTE---
CREATE TABLE ERP_O_ACCT_MDSE_ROUTE
(
TRANSFER_ID           NUMBER NOT NULL,
TRANSFER_STATUS       NUMBER DEFAULT 0 NOT NULL CONSTRAINT CHK_ERP_O_ACCT_MDSE_ROUTE_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
BUSINESSUNITCODE      VARCHAR2(6) NULL,
ROUTECODE             VARCHAR2(6) NULL,
RTE_TYPE_CODE         VARCHAR2(1) NULL,
PLANT_DRIVER          VARCHAR2(6) NULL,
DRIVERNUMBER          NUMBER NULL,
ROUTEMANAGER_PLANT    VARCHAR2(6) NULL,
ROUTEMANAGERNUMBER    NUMBER NULL,
SERVICEMANAGER_PLANT  VARCHAR2(6) NULL,
SERVICEMANAGER_NUMBER NUMBER NULL,
ROUTE_INACTIVEDATE    DATE NULL,
ESB_ERR_CODE          VARCHAR2(20) NULL,
ESB_ERR_DESC          VARCHAR2(500) NULL,
INST_ID               VARCHAR2(40) NULL,
STATUS                VARCHAR2(1) DEFAULT 'C' NULL CONSTRAINT CHK_ERP_O_ACCT_MDSE_ROUTE_V2 CHECK (STATUS IN ('C','P','E'))
);
COMMENT ON COLUMN  ERP_O_ACCT_MDSE_ROUTE.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
ALTER TABLE ERP_O_ACCT_MDSE_ROUTE
  ADD CONSTRAINT ERP_O_ACCT_MDSE_ROUTE PRIMARY KEY (TRANSFER_ID);
CREATE INDEX INDX01_ERP_O_ACCT_MDSE_ROUTE ON ERP_O_ACCT_MDSE_ROUTE(ROUTECODE);  

-- ERP_O_O_ACCT_MDSE_ROUTE_LOG --
CREATE TABLE ERP_O_ACCT_MDSE_ROUTE_LOG
(
  TRANSFER_ID     NUMBER NOT NULL,
  TRANSFER_STATUS NUMBER DEFAULT 0 NOT NULL  CONSTRAINT CHK_ERP_O_ACCT_MDSE_ROU_LOG_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
  TEXT            VARCHAR2(1000) NULL,
  PROCESS_STATUS  NUMBER DEFAULT 0 NOT NULL,
  TIMESTAMP       DATE DEFAULT SYSDATE NOT NULL
);
COMMENT ON COLUMN  ERP_O_ACCT_MDSE_ROUTE_LOG.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN  ERP_O_ACCT_MDSE_ROUTE_LOG.PROCESS_STATUS
  IS '0 = processed correctly, 1 = process stopped with errors';
ALTER TABLE ERP_O_ACCT_MDSE_ROUTE_LOG
  ADD CONSTRAINT PK_ERP_O_ACCT_MDSE_ROUTE_LOG PRIMARY KEY (TRANSFER_ID);
ALTER TABLE ERP_O_ACCT_MDSE_ROUTE_LOG
  ADD CONSTRAINT FK_ERP_O_ACCT_MDSE_ROUTE_LOG FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_O_ACCT_MDSE_ROUTE(TRANSFER_ID) ON DELETE CASCADE;
