CREATE TABLE CANCELAMENTO
(
    IDCANC            VARCHAR2(10)          NOT NULL,
    CDFILIAL          VARCHAR2(4)           NOT NULL,
    CDCAIXA           VARCHAR2(3)           NOT NULL,
    NRSEQVENDA        VARCHAR2(10)          NULL,
    IDORIGEMCANC      VARCHAR2(50)          NOT NULL,
    DSCANC            VARCHAR2(2000)        NOT NULL,
    IDINTEGRACAO      VARCHAR2(3)           NULL,
    NRPEDMOBILE       VARCHAR2(50)          NOT NULL,
    NRCOMANDAEXT      VARCHAR2(50)          NOT NULL,
    DTCANC            DATE                  NOT NULL,
    DTHRABERMESA      DATE                  NOT NULL,
    VRDESCOMANDA      FLOAT(126)            NOT NULL,
    VRACRCOMANDA      FLOAT(126)            NOT NULL,
    NRORG             NUMBER 	      		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     		DEFAULT 'S' 					NOT NULL
		CONSTRAINT CKC_IDATIVO_CANCELAMENTO CHECK (IDATIVO IN ('S','N')),
    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 PK_CANCELAMENTO PRIMARY KEY (IDCANC)
)
/

CREATE TABLE ITCANCELAMENTO
(
    IDCANC            VARCHAR2(10)          NOT NULL,
    CDFILIAL          VARCHAR2(4)           NOT NULL,
    NRPRODCOMVEN      VARCHAR2(6)           NOT NULL,
    CDPRODUTO         VARCHAR2(10)          NOT NULL,
    QTPRODCOMVEN      FLOAT(126)            NOT NULL,
    VRPRECCOMVEN      FLOAT(126)            NOT NULL,
    VRDESCCOMVEN      FLOAT(126)            NOT NULL,
    VRACRCOMVEN       FLOAT(126)            NOT NULL,
    NRSEQPRODCOM      VARCHAR2(3)           NOT NULL,
    CDPRODPROMOCAO    VARCHAR2(10)          NOT NULL,
    NRORG             NUMBER 	      		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     		DEFAULT 'S' 					NOT NULL
		CONSTRAINT CKC_IDATIVO_ITCANCELAMENTO CHECK (IDATIVO IN ('S','N')),
    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 PK_ITCANCELAMENTO PRIMARY KEY (IDCANC, NRPRODCOMVEN)
)
/