CREATE TABLE DADOSNFTECNOSPEED(
    CDFILIAL           VARCHAR2(04)                                                  NOT NULL,
    NRLANCTONF         VARCHAR2(10)                                                  NOT NULL,
    CDSERIERPS         VARCHAR2(05),
    NRRPS              VARCHAR2(15),
    NRNOTAFISCNFSE     VARCHAR2(30),
    CDVERIFNFSE        VARCHAR2(30),
    NRPROTECNOSPEED    VARCHAR2(100),
    NRPROTOPREFE       VARCHAR2(100),
    DTHPROTOPREFE      VARCHAR2(100),
    DTEMISSAO          DATE,
    DTCOMPETENCIA      DATE,
    DTVENCIMENTO       DATE,
    IDSTATUSNFSE       VARCHAR2(01)     DEFAULT 'P'                                 NOT NULL,
    DSOBSSTATUSNFSE    VARCHAR2(4000),
    IDINTEGRACAO       VARCHAR2(50),
    CDPRESTADOR        VARCHAR2(14),
    IDNOTAFISCAL       VARCHAR2(50),
	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',
    NRPROTCANPREFE     VARCHAR2(100),
    DTHPROTCANPREFE    VARCHAR2(100),
    DSOBSCANNFSE       VARCHAR2(4000),
    DSOBSCANPREFE      VARCHAR2(4000),
		CONSTRAINT CKC_00000001 CHECK (IDSTATUSNFSE IN ('C', 'D', 'O', 'P', 'R', 'T')),
		CONSTRAINT CKC_IDATIVO_DADOSNFTECNOSPEED CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_DADOSNFTECNOSPEED PRIMARY KEY (CDFILIAL, NRLANCTONF)
)
/

ALTER TABLE DADOSNFTECNOSPEED ADD CONSTRAINT FKFIS00891DADOSNFTECNOSPEED FOREIGN KEY (CDFILIAL, NRLANCTONF)
	REFERENCES NOTAFISCAL (CDFILIAL, NRLANCTONF) ON DELETE CASCADE
/
CREATE INDEX FIS00891_FK ON DADOSNFTECNOSPEED (CDFILIAL,NRLANCTONF)
/

ALTER TABLE GERPARAMGERAL ADD CDAPIKEY VARCHAR2(100)
/

UPDATE GERPARAMGERAL
   SET CDAPIKEY = 'b884f0dce10b9f1774e56c2e23b6a205'
 WHERE CDPARGERAL = '0001'
/

COMMIT
/

ALTER TABLE PARAMNFSEINSCMUNI ADD IDCERTTECNOSPEED VARCHAR2(100)
/