-- ABS-125581 New checkbox "Use Alternate Sorting with Stack change" in Sorting Definition dlg / ABS-128111

---------------------------CUSTOMERSORTINGDEFINITION------------------------------
CREATE TABLE CUSTOMERSORTINGDEFINITION
(      CUSTOMER_ID              NUMBER NOT NULL,
       ALTSORTINGSTACKCHANGE    VARCHAR2(1) DEFAULT 'N' NOT NULL,
       STACKCHANGEPERPIECE      VARCHAR2(1) DEFAULT 'N' NOT NULL,
       SYSTEMUSER_ID            NUMBER DEFAULT 0 NOT NULL,
       TIMESTAMP                DATE DEFAULT SYSDATE NOT NULL
);

ALTER TABLE CUSTOMERSORTINGDEFINITION
      ADD CONSTRAINT XPKCUSTOMERSORTINGDEFINITION PRIMARY KEY(CUSTOMER_ID);
      
ALTER TABLE CUSTOMERSORTINGDEFINITION
      ADD CONSTRAINT FK_CUSTOMERSORTINGDEFINITION_CUSTOMER_ID FOREIGN KEY(CUSTOMER_ID)
      REFERENCES CUSTOMER(CUSTOMER_ID) ON DELETE CASCADE;

ALTER TABLE CUSTOMERSORTINGDEFINITION 
      ADD CONSTRAINT CHK_CUSTSORTDEF_ALTSORTINGSTACKCHANGE
      CHECK (NOT((ALTSORTINGSTACKCHANGE = 'Y') AND (STACKCHANGEPERPIECE ='Y')));
      
ALTER TABLE CUSTOMERSORTINGDEFINITION
      ADD CONSTRAINT CHK_CUSTSORTDEF_STACKCHANGEPERPIECE
      CHECK (NOT((ALTSORTINGSTACKCHANGE = 'Y') AND (STACKCHANGEPERPIECE ='Y')));       
     

COMMENT ON COLUMN CUSTOMERSORTINGDEFINITION.ALTSORTINGSTACKCHANGE
        IS 'Y/N default N';  
COMMENT ON COLUMN CUSTOMERSORTINGDEFINITION.STACKCHANGEPERPIECE
        IS 'Y/N default N';  
