--order 502747
/*
      ACTION is CREATE Table PACKINGNOTELINEDETAILS
      */

CREATE TABLE PACKINGNOTELINEDETAILS (
       PACKINGNOTELINEDETAILS_ID NUMBER NOT NULL,
       PACKINGNOTELINE_ID   NUMBER NOT NULL,
       ITEMNUMBER           NUMBER DEFAULT 1 NOT NULL,
       QUANTITY             NUMBER DEFAULT 1 NOT NULL,
       INSTRUCTIONS         CLOB NULL
);

CREATE UNIQUE INDEX XAK1PACKINGNOTELINEDETAILS ON PACKINGNOTELINEDETAILS
(
       PACKINGNOTELINE_ID             ASC,
       ITEMNUMBER                     ASC
);

CREATE INDEX XIF1PACKINGNOTELINEDETAILS ON PACKINGNOTELINEDETAILS
(
       PACKINGNOTELINE_ID             ASC
);


ALTER TABLE PACKINGNOTELINEDETAILS
       ADD  ( CONSTRAINT XPKPACKINGNOTELINEDETAILS PRIMARY KEY (
              PACKINGNOTELINEDETAILS_ID) ) ;

      
      /*
      ACTION is CREATE Table STANDARDDELIVERYAMNTDETAILS
      */

CREATE TABLE STANDARDDELIVERYAMNTDETAILS (
       STANDARDDELIVERYAMNTDETAILS_ID NUMBER NOT NULL,
       STANDARDDELIVERYLINE_ID NUMBER NOT NULL,
       ITEMNUMBER           NUMBER DEFAULT 1 NOT NULL,
       QUANTITY             NUMBER DEFAULT 1 NOT NULL,
       INSTRUCTIONS         CLOB NULL
);

CREATE UNIQUE INDEX XAK1STANDARDDELIVERYAMNTDETAIL ON STANDARDDELIVERYAMNTDETAILS
(
       STANDARDDELIVERYLINE_ID        ASC,
       ITEMNUMBER                     ASC
);

CREATE INDEX XIF1STANDARDDELIVERYAMNTDETAIL ON STANDARDDELIVERYAMNTDETAILS
(
       STANDARDDELIVERYLINE_ID        ASC
);


ALTER TABLE STANDARDDELIVERYAMNTDETAILS
       ADD  ( CONSTRAINT XPKSTANDARDDELIVERYAMNTDETAILS PRIMARY KEY (
              STANDARDDELIVERYAMNTDETAILS_ID) ) ;


ALTER TABLE PACKINGNOTELINEDETAILS
       ADD  ( CONSTRAINT PACKINGNOTELINEDETAILS_PACKING
              FOREIGN KEY (PACKINGNOTELINE_ID)
                             REFERENCES PACKINGNOTELINE
                             ON DELETE CASCADE ) ;


ALTER TABLE STANDARDDELIVERYAMNTDETAILS
       ADD  ( CONSTRAINT STANDARDDELIVERYAMNTDETAILS_ST
              FOREIGN KEY (STANDARDDELIVERYLINE_ID)
                             REFERENCES STANDARDDELIVERYLINE
                             ON DELETE CASCADE ) ;





