ALTER TABLE CLIENTE ADD IDENVBOLANTNOTA VARCHAR2(1) DEFAULT 'N' NOT NULL
/ 

ALTER TABLE CLIENTE ADD CONSTRAINT CKC_IDENVBOLANTNOTA_CLIENTE CHECK (IDATIVO IN ('S', 'N')) 
/ 
CREATE TABLE PARAMNOTIFICECO
( 
    CDFILIAL 			VARCHAR2(4)		NOT NULL,
    IDTPNOTIFIC 		VARCHAR2(1)		NOT NULL
		CONSTRAINT CKC_IDTPNOTIFIC_PARNOTCECO CHECK (IDTPNOTIFIC IN ('A','C')),
    IDENVIANOTIFIC 		VARCHAR2(1)  	DEFAULT 'S' NOT NULL
 		CONSTRAINT CKC_IDENVIANOTIFIC_PARNOTCECO CHECK (IDENVIANOTIFIC IN ('S','N')),
    NRDIASANTESNOTIFIC 	NUMBER		NOT NULL,
    TXEMAILNOTIFIC 		CLOB,
    NRORG 				NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO 			VARCHAR2(1) DEFAULT 'S' NOT NULL,
		CONSTRAINT CKC_IDATIVO_PARAMNOTIFICECO CHECK (IDATIVO IN ('S','N')),
	DTINCLUSAO 			DATE 				NULL,
	DTULTATU 			DATE 			NULL,
	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 PK_PARAMNOTIFICECO PRIMARY KEY (CDFILIAL, IDTPNOTIFIC)
)
/

CREATE INDEX PLA01217FILIAL_FK ON PARAMNOTIFICECO (CDFILIAL ASC)
/

ALTER TABLE PARAMNOTIFICECO 	
	ADD CONSTRAINT FKPLA01217FILIAL FOREIGN KEY (CDFILIAL)
		REFERENCES FILIAL (CDFILIAL)
/
ALTER TABLE MAPAAPURACAUTO ADD CDGRUPINSCESTA VARCHAR2(10) 
/

ALTER TABLE MAPAAPURACAUTO ADD IDTPAPAUTO VARCHAR2(1) DEFAULT 'T' NOT NULL
/

ALTER TABLE MAPAAPURACAUTO ADD CONSTRAINT CKC_IDTPAPAUTO_MAPAAPURACAUTO CHECK (IDTPAPAUTO IN ('T','L','A'))
/
CREATE TABLE ARQMAPAAPURAUTO
(	
    NRARQUIVO 			NUMBER		 	NOT NULL, 
	NRSEQUJOB 			NUMBER 			NOT NULL , 
	NRSEQUMAPAPU 		NUMBER 			NOT NULL , 
	CDEMPRESA 			VARCHAR2(4000) 	NOT NULL , 
	CDINSCESTA 			VARCHAR2(4000), 
	DTAGENDAMENTO 		DATE 			NOT NULL , 
	NMARQUIVO 			VARCHAR2(50) 	NOT NULL , 
	NMPATHARQ 			VARCHAR2(200) 	NOT NULL , 
    NRORG 				NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' NOT NULL,
		CONSTRAINT CKC_IDATIVO_ARQMAPAAPURAUTO CHECK (IDATIVO IN ('S','N')),
	DTINCLUSAO 			DATE 			NULL,
	DTULTATU 			DATE 			NULL,
	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 PK_ARQMAPAAPURAUTO PRIMARY KEY (NRARQUIVO)
)