/*ORDER 502366*/    

      /*
      ACTION is CREATE Table GLEXPORT
      */

CREATE SEQUENCE SEQ_GLEXPORT
START WITH 1
INCREMENT BY 1 ;

CREATE TABLE GLEXPORT (
       GLEXPORT_ID          NUMBER NOT NULL,
       SET_OF_BOOKS_ID      NUMBER(22) NOT NULL,
       ACCOUNTING_DATE      DATE NOT NULL,
       DATE_CREATED         DATE NOT NULL,
       SEGMENT1             VARCHAR2(25) NOT NULL,
       SEGMENT2             VARCHAR2(25) NOT NULL,
       SEGMENT3             VARCHAR2(25) NOT NULL,
       SEGMENT4             VARCHAR2(25) NOT NULL,
       SEGMENT5             VARCHAR2(25) NOT NULL,
       SEGMENT6             VARCHAR2(25) NOT NULL,
       AMOUNT_DR            NUMBER(22) NULL,
       AMOUNT_CR            NUMBER(22) NULL,
       DESCRIPTION          VARCHAR2(100) NOT NULL,
       IMPORTDATE           DATE NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE UNIQUE INDEX XAK1GLEXPORT ON GLEXPORT
(
       ACCOUNTING_DATE                ,
       SEGMENT1                       ,
       SEGMENT2                       ,
       SEGMENT3                       ,
       SEGMENT4                       
);


ALTER TABLE GLEXPORT
       ADD  ( CONSTRAINT XPKGLEXPORT PRIMARY KEY (GLEXPORT_ID) ) ;

      
      /*
      CHANGE REPORT for Table ARTRANSACTION
          - Adding a new relationship ARTRANSACTION_GLEXPORT_ID
          WARNING : Create FK statement may fail (existing data may violate the new FK rules: adding a new FK ARTRANSACTION_GLEXPORT_ID of table ARTRANSACTION, which references table GLEXPORT).
          - Adding column GLEXPORT_ID
      ACTION is ALTER or modify Table ARTRANSACTION
      */

ALTER TABLE ARTRANSACTION ADD (GLEXPORT_ID          NUMBER NULL);

CREATE INDEX XIF14ARTRANSACTION ON ARTRANSACTION
(
       GLEXPORT_ID  ASC
);

ALTER TABLE ARTRANSACTION
       ADD  ( CONSTRAINT ARTRANSACTION_GLEXPORT_ID
              FOREIGN KEY (GLEXPORT_ID)
                             REFERENCES GLEXPORT ON DELETE SET NULL ) ;



