--ABS-92950
CREATE TABLE ERP_U_PLPC
(
  TRANSFER_ID           NUMBER NOT NULL,
  TRANSFER_STATUS       NUMBER DEFAULT 0 NOT NULL CONSTRAINT CHK_ERP_U_PLPC_V1 CHECK (TRANSFER_STATUS IN (-1,0,1)),
  CUSTOMERNUMBER        NUMBER NOT NULL,
  PRODUCTCODE           VARCHAR2(12) NOT NULL,
  CUSTOMCODE            VARCHAR2(16),
  CUSTOMDESCRIPTION     VARCHAR2(30)
);
COMMENT ON COLUMN ERP_U_PLPC.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN ERP_U_PLPC.CUSTOMCODE
  IS   'Customer specific code';
COMMENT ON COLUMN ERP_U_PLPC.CUSTOMDESCRIPTION
  IS   'Customer specific description';
ALTER TABLE ERP_U_PLPC
 ADD CONSTRAINT PK_ERP_U_PLPC PRIMARY KEY (TRANSFER_ID);
CREATE INDEX INDX01_ERP_U_PLPC ON ERP_U_PLPC(TRANSFER_STATUS);

CREATE TABLE ERP_U_PLPC_LOG
(
  TRANSFER_ID     NUMBER NOT NULL,
  TRANSFER_STATUS NUMBER DEFAULT 0 NOT NULL  CONSTRAINT CHK_ERP_U_PLPC_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_U_PLPC_LOG.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN ERP_U_PLPC_LOG.PROCESS_STATUS
  IS '0 = processed correctly, 1 = process stopped with errors';
ALTER TABLE ERP_U_PLPC_LOG
  ADD CONSTRAINT PK_ERP_U_PLPC_LOG PRIMARY KEY (TRANSFER_ID);
ALTER TABLE ERP_U_PLPC_LOG
  ADD CONSTRAINT FK_ERP_U_PLPC_LOG FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_U_PLPC(TRANSFER_ID) ON DELETE CASCADE;