CREATE TABLE PAGELETRONICO
(
   NRSEQUENCIAL       VARCHAR2(20)        NOT NULL,
   CDEMPRESA          VARCHAR2(02)        NULL,
   CDINSCESTA         VARCHAR2(16)        NULL,
   IDORIGEM           VARCHAR2(05)        NULL,
   CDFILIAL           VARCHAR2(4)         NULL,
   NRLANCTONF         VARCHAR2(10)        NULL,
   CDFILIBOLREC       VARCHAR2(4)         NULL,
   NRLANBOLREC        VARCHAR2(10)        NULL,
   DTEMISSAO          DATE                NULL,
   CDTIPORECE         VARCHAR2(3)         NULL,
   DTPAGAMENTO        DATE                NULL,
   VRNOTAFISC         FLOAT               NULL,
   VRRECEBIMENTO      FLOAT               NULL,
   VRICMS             FLOAT               NULL,
   VRISS              FLOAT               NULL,
   VROUTROS           FLOAT               NULL,
   NRCNPJPAG          VARCHAR2(20)        NULL,
   NRCNPJPAGTRANS     VARCHAR2(20)        NULL,
   DTINIAPUR          DATE                NULL,
   DTFIMAPUR          DATE                NULL,
   IDRECEGARANTIDO    VARCHAR2(1)         NULL,
   NRSEQUMAPAPU       VARCHAR2(10)        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_PAGELETRONICO CHECK (IDATIVO IN ('S','N')),
	CONSTRAINT PK_PAGELETRONICO PRIMARY KEY (NRSEQUENCIAL)
)
/ 


ALTER TABLE TIPORECE ADD IDMEIOPAGELE VARCHAR2(1) NULL
	CONSTRAINT CKC_IDMEIOPAGELE_TIPORECE 
		CHECK (IDMEIOPAGELE IS NULL OR (IDMEIOPAGELE IN ('S','N')))
/

ALTER TABLE TIPORECE ADD IDRECEGARANTIDO VARCHAR2(1) NULL
	CONSTRAINT CKC_IDRECEGARANTIDO_TIPORECE CHECK (IDRECEGARANTIDO IS NULL OR (IDRECEGARANTIDO IN ('S','N')))
/

ALTER TABLE TIPORECE ADD NMRAZADMCARTTRANS  VARCHAR2(100) NULL
/

ALTER TABLE TIPORECE ADD DSENDERECETRANS  VARCHAR2(50) NULL
/ 

ALTER TABLE TIPORECE ADD CDPAISTRANS VARCHAR2(4)  NULL
/ 

ALTER TABLE TIPORECE ADD SGESTADOTRANS VARCHAR2(2) NULL
/ 
 
ALTER TABLE TIPORECE ADD CDMUNICIPIOTRANS VARCHAR2(4) NULL
/ 
 
ALTER TABLE TIPORECE ADD CDBAIRROTRANS  VARCHAR2(10)  NULL
/

ALTER TABLE TIPORECE ADD NRCEPRECETRANS  VARCHAR2(15)  NULL
/

ALTER TABLE TIPORECE ADD DSCOMPLERECETRANS  VARCHAR2(100) NULL
/

ALTER TABLE TIPORECE ADD DSLOGRECETRANS  VARCHAR2(40)  NULL
/ 

ALTER TABLE TIPORECE ADD NRENDERECETRANS VARCHAR2(10)  NULL
/ 

ALTER TABLE TIPORECE ADD NRCNPJPAG  VARCHAR2(20) NULL
/  

ALTER TABLE TIPORECE ADD NRCNPJPAGTRANS VARCHAR2(20) NULL
/

UPDATE TIPORECE
SET NRCNPJPAG = CDADMINCART
WHERE CDADMINCART IS NOT NULL AND  NRCNPJPAG  IS NULL
/
COMMIT
/