CREATE TABLE ITEMSCEMAILAPRGER (
	NRITEMSCEMAILAPRGER INTEGER  		NOT NULL,
	CDFILSOLI           VARCHAR2(4)	    NOT NULL ,    
	CDFILLAN            VARCHAR2(4)  	NOT NULL ,    
	NRSOLICMP           VARCHAR2(10)    NOT NULL ,   
	CDPRODUTO           VARCHAR2(10)    NOT NULL ,  
	CDOPERADOR          VARCHAR2(12)    NOT NULL ,  
	STATUS              VARCHAR2(1) 	NOT NULL ,    
	NRORG             	NUMBER 	        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO            	VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO          DATE            DEFAULT SYSDATE,
    DTULTATU          	DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     	NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    	VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       	NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      	VARCHAR2(12)    DEFAULT '1',
	   CONSTRAINT CKC_IDATIVO_ITEMSCEMAILAPRGER  CHECK (IDATIVO IN ('S','N')),
	   CONSTRAINT PK_ITEMSCEMAILAPRGER PRIMARY KEY (NRITEMSCEMAILAPRGER),
	   CONSTRAINT UN_ITEMSCEMAILAPRGER UNIQUE (CDFILSOLI, CDFILLAN, NRSOLICMP, CDPRODUTO, CDOPERADOR),
	   CONSTRAINT FKSUP00684ITEMSCEMAILAPRGER FOREIGN KEY (CDFILSOLI, CDFILLAN, NRSOLICMP) REFERENCES SOLICITA(CDFILSOLI, CDFILLANCA, NRSOLICMP) ON DELETE CASCADE
)
/
CREATE INDEX SUP00684_FK ON ITEMSCEMAILAPRGER  (CDFILSOLI, CDFILLAN, NRSOLICMP) 
/

CREATE SEQUENCE SEQ_ITEMSCEMAILAPRGER INCREMENT BY 1 MINVALUE 1
/

CREATE INDEX IN_PRAZOFORNEXPEDFIL_2 ON  PRAZOFORNEXPEDFIL(CDFORNECED, CDFILIAL, QTDIASPRAZOEXPED)    
/

CREATE INDEX IN_PRAZOFORNEXPEDFILPROD_2 ON  PRAZOFORNEXPEDFILPROD(CDFORNECED, CDFILIAL, CDPRODUTO, QTDIASPRAZOEXPED) 
/