CREATE TABLE NCSERVASS
(
	NRSERVASS 		  VARCHAR2(10),
	CDNCSERVASS 	  VARCHAR2(5),
	NMSERVASS 		  VARCHAR2(50),
	DTVINGINI 		  DATE,
	DTVINGFIM 		  DATE,
	URLARQTERMO 	  VARCHAR2(200),
	NRFILASSOC 		  VARCHAR2(10),
	VRNCSERVASS 	  FLOAT(126),
	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_NCSERVASS CHECK (IDATIVO IN ('S','N'))
 )
/
CREATE TABLE NCFILASSOC
(
	NRFILASSOC VARCHAR2(10),
	CDFILIAL VARCHAR2(4),
	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_NCFILASSOC CHECK (IDATIVO IN ('S','N'))
 )
/
CREATE TABLE NCPARAMFIN
(
	NRPARAMFIN VARCHAR2(10),
	CDFILIAL VARCHAR2(4),
	DSFORMPG VARCHAR2(20),
	CDCONTREC VARCHAR2(6),
	CDCONTCOR VARCHAR2(3),
	CDTPOPER VARCHAR2(2),
	CDTPBAIXAREC VARCHAR2(2),
	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_NCPARAMFIN CHECK (IDATIVO IN ('S','N'))
 )
/
CREATE TABLE TEMP_RECHARGE
(
	CDCLIENTE 		  VARCHAR(21),
	CDFILIAL 	 	  VARCHAR(4),
	CDTIPOCONS 		  VARCHAR2(2),
	NRTRANSACAO 	  VARCHAR2(12) PRIMARY KEY,
	TIPORECE 		  VARCHAR2(3),
	NSU 			  VARCHAR2(30),
	NIT 			  VARCHAR2(64),
	CDCONSUMIDOR 	  VARCHAR2(21),
	CDFAMILISALD 	  VARCHAR2(3),
	RECHARGE_VALUES   VARCHAR2(4000),
	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_TEMP_RECHARGE CHECK (IDATIVO IN ('S','N'))
)
/
CREATE TABLE NCSERVASSASSOC
(
	NRSERVASSCLI 	  VARCHAR2(10),
	NRSERVASS 		  VARCHAR2(10),
	VRNCSERVASS 	  FLOAT(126),
	NUMPARCELAS 	  NUMBER,
	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_NCSERVASSASSOC CHECK (IDATIVO IN ('S','N'))
)
/
CREATE TABLE NCSERVASSCLI
(
	CDCLIENTE 		  VARCHAR(21),
	CDFILIAL 		  VARCHAR(4),
	CDCONSUMIDOR 	  VARCHAR2(21),
	NRCPFRESPCON 	  VARCHAR2(11),
	NRSERVASSCLI 	  VARCHAR2(10),
	VLRASS 			  FLOAT(126),
	DTASSINATURA 	  DATE,
	IDSTATUSBOLREC 	  VARCHAR2(01) 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_NCSERVASSCLI CHECK (IDATIVO IN ('S','N'))
)
/
ALTER TABLE NCSERVASSCLI ADD CONSTRAINT PK_NCSERVASSCLI PRIMARY KEY
(NRSERVASSCLI)