CREATE GLOBAL TEMPORARY TABLE TMP_DETALHAMENTO_VENDAS
(
   CDREGISTRO      VARCHAR2(04)   NOT NULL,
   NRSEQVENDA      VARCHAR2(1000) NOT  NULL,
   CDCAIXA         VARCHAR2(1000) NOT  NULL,
   CDLOJA          VARCHAR2(1000) NOT  NULL,
   CDFILIAL        VARCHAR2(1000) NOT  NULL,
   NMFILIAL        VARCHAR2(1000)   NULL,
   NMLOJA          VARCHAR2(1000)   NULL,
   LABELFILIAL     VARCHAR2(1000)   NULL,
   LABELLOJA       VARCHAR2(1000)   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_TMP_DTALHAMNT_VNDS CHECK (IDATIVO IN ('S','N')),
	CONSTRAINT PK_TMP_DETALHAMENTO_VENDAS PRIMARY KEY (CDREGISTRO)
) ON COMMIT PRESERVE ROWS  
/
CREATE GLOBAL TEMPORARY TABLE TMP_DETALHAMENTO_ITEMVENDAS
(
    CDREGISTRO      VARCHAR2(04)   NOT NULL,
    CDPRODUTO       VARCHAR2(1000) NOT  NULL,
    IDIMPPRODUTO    VARCHAR2(1000)   NULL,
    CDPRODPROMOCAO  VARCHAR2(1000)   NULL,
    IDTIPOCOMPPROD  VARCHAR2(1000)   NULL,
    CDNVPRODUTO     VARCHAR2(1000)   NULL,
    SGUNIDADE       VARCHAR2(1000)   NULL,
    NMPRODUTO       VARCHAR2(1000)   NULL,
    CDARVPROD       VARCHAR2(1000)   NULL,
    CDPRODNIVANTE   VARCHAR2(1000)   NULL,
    GRUPOSUPERIOR   VARCHAR2(1000)   NULL,
    NRSEQUITVEND    VARCHAR2(1000)   NULL,
    QTDENORMAL      VARCHAR2(1000)   NULL,
    TOTAL           VARCHAR2(1000)   NULL,
    VRUNITVEND      VARCHAR2(1000)   NULL,
    VRUNITVENDCL    VARCHAR2(1000)   NULL,
    QTDEPROM        VARCHAR2(1000)   NULL,
    PRECMEDIO       VARCHAR2(1000)   NULL,
    DTVENDA         VARCHAR2(1000)   NULL,
    NRSEQVENDA      VARCHAR2(1000)   NULL,
    CDFILIAL        VARCHAR2(1000)   NULL,
    CDCAIXA         VARCHAR2(1000)   NULL,
    CDLOJA          VARCHAR2(1000)   NULL,
    NMFILIAL        VARCHAR2(1000)   NULL,
    NMLOJA          VARCHAR2(1000)   NULL,
    LABELFILIAL     VARCHAR2(1000)   NULL,
    LABELLOJA       VARCHAR2(1000)   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_TMP_DTLMNT_ITMVNDS CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_TMP_DETALHAMENTO_ITEMVENDAS PRIMARY KEY (CDREGISTRO)
) ON COMMIT PRESERVE ROWS
/
