Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************/
- /*** Generated by IBExpert 13/07/2018 14:07:14 ***/
- /******************************************************************************/
- /******************************************************************************/
- /*** Following SET SQL DIALECT is just for the Database Comparer ***/
- /******************************************************************************/
- SET SQL DIALECT 3;
- /******************************************************************************/
- /*** Tables ***/
- /******************************************************************************/
- CREATE GENERATOR GEN_ITENS_VENDA_ID;
- CREATE TABLE ITENS_VENDA (
- ID INTEGER NOT NULL,
- VENDA_NUMERO INTEGER,
- ECF_CCO NUMERIC(15,0),
- ECF_CCF NUMERIC(15,0),
- ECF_NSERIE VARCHAR(35),
- ECF_NUMERO NUMERIC(4,0),
- ECF_MARCA VARCHAR(35),
- ECF_MODELO VARCHAR(35),
- ITENS_IDPRODUTO INTEGER,
- ITENS_CODBARRAS VARCHAR(13),
- ITENS_DESCPRODUTO VARCHAR(120) CHARACTER SET WIN1252,
- ITENS_POSICAOITEN INTEGER,
- ITENS_QUANTIDADE FLOAT DEFAULT 1,
- ITENS_VLUN FLOAT DEFAULT 0,
- ITENS_TOTAL FLOAT DEFAULT 0,
- ITENS_DATAVENDA DATE,
- ITENS_HORADAVENDA TIME,
- ITENS_USUARIO VARCHAR(60),
- ITENS_CAIXAID INTEGER,
- ITENS_SITUACAO VARCHAR(10),
- SAT_NUMEROCFE INTEGER,
- SAT_SERIALSAT VARCHAR(35),
- ITENS_UN VARCHAR(3) CHARACTER SET WIN1252,
- ITENS_DESCVL NUMERIC(15,2) DEFAULT 0,
- ITENS_DESCPERCENT NUMERIC(15,2) DEFAULT 0,
- ITENS_CFOP VARCHAR(5),
- ITENS_CST VARCHAR(4),
- ITENS_NCM VARCHAR(10),
- ITENS_CEST VARCHAR(10),
- IMPOSTO_VPIS FLOAT DEFAULT 0,
- IMPOSTO_PISCST VARCHAR(4) DEFAULT 0,
- IMPOSTO_PISVBC FLOAT DEFAULT 0,
- IMPOSTO_PISPPIS FLOAT DEFAULT 0,
- IMPOSTO_COFINSCST VARCHAR(4),
- IMPOSTO_COFINSVBC FLOAT DEFAULT 0,
- IMPOSTO_COFINSPCOFINS FLOAT DEFAULT 0,
- INFADPROD VARCHAR(100),
- IMPOSTO_ICMSCST VARCHAR(4),
- IMPOSTO_ICMSPICMS FLOAT DEFAULT 0,
- IMPOSTO_ICMSCSOSN VARCHAR(8),
- IMPOSTO_ICMSORIGDESC VARCHAR(35),
- "IMPOSTO.ICMS.ORIG" VARCHAR(3),
- CANCELITEM_VLCANC FLOAT DEFAULT 0,
- IMPOSTO_TRIBDESC VARCHAR(35),
- TRANSF_BOOL INTEGER,
- MARCA VARCHAR(80),
- GRUPO VARCHAR(80),
- SUBGRUPO VARCHAR(80),
- IDMARCA INTEGER,
- IDGRUPO INTEGER,
- IDSUBGRUPO INTEGER,
- IDFORNECEDOR INTEGER,
- FORNECEDOR VARCHAR(120),
- PDV_NUMERO INTEGER,
- IBPX_TFNACIONAL NUMERIC(15,2) DEFAULT 0,
- IBPX_TFIMPORTADO NUMERIC(15,2) DEFAULT 0,
- IBPTX_ESTADUAL NUMERIC(15,2) DEFAULT 0,
- IBPTX_MUINICIPAL NUMERIC(15,2) DEFAULT 0
- );
- /******************************************************************************/
- /*** Primary Keys ***/
- /******************************************************************************/
- ALTER TABLE ITENS_VENDA ADD CONSTRAINT PK_ITENS_VENDA PRIMARY KEY (ID);
- /******************************************************************************/
- /*** Indices ***/
- /******************************************************************************/
- CREATE INDEX ITENS_VENDA_IDX1 ON ITENS_VENDA (ID);
- /******************************************************************************/
- /*** Triggers ***/
- /******************************************************************************/
- SET TERM ^ ;
- /******************************************************************************/
- /*** Triggers for tables ***/
- /******************************************************************************/
- /* Trigger: ITENS_VENDAREPLICAR */
- CREATE OR ALTER TRIGGER ITENS_VENDAREPLICAR FOR ITENS_VENDA
- ACTIVE AFTER INSERT OR UPDATE POSITION 2
- AS
- BEGIN
- /* Trigger text */
- UPDATE OR INSERT INTO itensvenda_reply (ID, VENDA_NUMERO, ECF_CCO, ECF_CCF, ECF_NSERIE, ECF_NUMERO, ECF_MARCA, ECF_MODELO,
- ITENS_IDPRODUTO, ITENS_CODBARRAS, ITENS_DESCPRODUTO, ITENS_POSICAOITEN,
- ITENS_QUANTIDADE, ITENS_VLUN, ITENS_TOTAL, ITENS_DATAVENDA, ITENS_HORADAVENDA,
- ITENS_USUARIO, ITENS_CAIXAID, ITENS_SITUACAO, SAT_NUMEROCFE, SAT_SERIALSAT, ITENS_UN,
- ITENS_DESCVL, ITENS_DESCPERCENT, ITENS_CFOP, ITENS_CST, ITENS_NCM, ITENS_CEST,
- IMPOSTO_VPIS, IMPOSTO_PISCST, IMPOSTO_PISVBC, IMPOSTO_PISPPIS, IMPOSTO_COFINSCST,
- IMPOSTO_COFINSVBC, IMPOSTO_COFINSPCOFINS, INFADPROD, IMPOSTO_ICMSCST,
- IMPOSTO_ICMSPICMS, IMPOSTO_ICMSCSOSN, IMPOSTO_ICMSORIGDESC, "IMPOSTO.ICMS.ORIG",
- CANCELITEM_VLCANC, IMPOSTO_TRIBDESC, TRANSF_BOOL, MARCA, GRUPO, SUBGRUPO, IDMARCA,
- IDGRUPO, IDSUBGRUPO, IDFORNECEDOR, FORNECEDOR, PDV_NUMERO, IBPX_TFNACIONAL,
- IBPX_TFIMPORTADO, IBPTX_ESTADUAL, IBPTX_MUINICIPAL)
- VALUES (NEW.ID, NEW.VENDA_NUMERO, NEW.ECF_CCO, NEW.ECF_CCF, NEW.ECF_NSERIE, NEW.ECF_NUMERO, NEW.ECF_MARCA, NEW.ECF_MODELO, NEW.ITENS_IDPRODUTO,
- NEW.ITENS_CODBARRAS, NEW.ITENS_DESCPRODUTO, NEW.ITENS_POSICAOITEN, NEW.ITENS_QUANTIDADE, NEW.ITENS_VLUN, NEW.ITENS_TOTAL,
- NEW.ITENS_DATAVENDA, NEW.ITENS_HORADAVENDA, NEW.ITENS_USUARIO, NEW.ITENS_CAIXAID, NEW.ITENS_SITUACAO, NEW.SAT_NUMEROCFE,
- NEW.SAT_SERIALSAT, NEW.ITENS_UN, NEW.ITENS_DESCVL, NEW.ITENS_DESCPERCENT, NEW.ITENS_CFOP, NEW.ITENS_CST, NEW.ITENS_NCM, NEW.ITENS_CEST,
- NEW.IMPOSTO_VPIS, NEW.IMPOSTO_PISCST, NEW.IMPOSTO_PISVBC, NEW.IMPOSTO_PISPPIS, NEW.IMPOSTO_COFINSCST, NEW.IMPOSTO_COFINSVBC,
- NEW.IMPOSTO_COFINSPCOFINS, NEW.INFADPROD, NEW.IMPOSTO_ICMSCST, NEW.IMPOSTO_ICMSPICMS, NEW.IMPOSTO_ICMSCSOSN,
- NEW.IMPOSTO_ICMSORIGDESC, NEW."IMPOSTO.ICMS.ORIG", NEW.CANCELITEM_VLCANC, NEW.IMPOSTO_TRIBDESC, NEW.TRANSF_BOOL, NEW.MARCA,
- NEW.GRUPO, NEW.SUBGRUPO, NEW.IDMARCA, NEW.IDGRUPO, NEW.IDSUBGRUPO, NEW.IDFORNECEDOR, NEW.FORNECEDOR, NEW.PDV_NUMERO, NEW.IBPX_TFNACIONAL,
- NEW.IBPX_TFIMPORTADO, NEW.IBPTX_ESTADUAL, NEW.IBPTX_MUINICIPAL)
- matching (ID,ITENS_IDPRODUTO,VENDA_NUMERO);
- END
- ^
- /* Trigger: ITENS_VENDATRANSF */
- CREATE OR ALTER TRIGGER ITENS_VENDATRANSF FOR ITENS_VENDA
- INACTIVE AFTER INSERT OR UPDATE POSITION 1
- AS
- BEGIN
- UPDATE OR INSERT INTO ITENS_TRANSF (ID, VENDA_NUMERO, ECF_CCO, ECF_CCF, ECF_NSERIE, ECF_NUMERO, ECF_MARCA, ECF_MODELO,
- ITENS_IDPRODUTO, ITENS_CODBARRAS, ITENS_DESCPRODUTO, ITENS_POSICAOITEN,
- ITENS_QUANTIDADE, ITENS_VLUN, ITENS_TOTAL, ITENS_DATAVENDA, ITENS_HORADAVENDA,
- ITENS_USUARIO, ITENS_CAIXAID, ITENS_SITUACAO, SAT_NUMEROCFE, SAT_SERIALSAT,
- ITENS_UN, ITENS_DESCVL, ITENS_DESCPERCENT, ITENS_CFOP, ITENS_CST, ITENS_NCM,
- ITENS_CEST, IMPOSTO_VPIS, IMPOSTO_PISCST, IMPOSTO_PISVBC, IMPOSTO_PISPPIS,
- IMPOSTO_COFINSCST, IMPOSTO_COFINSVBC, IMPOSTO_COFINSPCOFINS, INFADPROD,
- IMPOSTO_ICMSCST, IMPOSTO_ICMSPICMS, IMPOSTO_ICMSCSOSN, IMPOSTO_ICMSORIGDESC,
- "IMPOSTO.ICMS.ORIG", CANCELITEM_VLCANC, IMPOSTO_TRIBDESC, TRANSF_BOOL, MARCA, GRUPO,
- SUBGRUPO, IDMARCA, IDGRUPO, IDSUBGRUPO, IDFORNECEDOR, FORNECEDOR, PDV_NUMERO,
- IBPX_TFNACIONAL, IBPX_TFIMPORTADO, IBPTX_ESTADUAL, IBPTX_MUINICIPAL)
- VALUES (NEW.ID, NEW.VENDA_NUMERO, NEW.ECF_CCO, NEW.ECF_CCF, NEW.ECF_NSERIE, NEW.ECF_NUMERO, NEW.ECF_MARCA, NEW.ECF_MODELO, NEW.ITENS_IDPRODUTO,
- NEW.ITENS_CODBARRAS, NEW.ITENS_DESCPRODUTO, NEW.ITENS_POSICAOITEN, NEW.ITENS_QUANTIDADE, NEW.ITENS_VLUN, NEW.ITENS_TOTAL,
- NEW.ITENS_DATAVENDA, NEW.ITENS_HORADAVENDA, NEW.ITENS_USUARIO, NEW.ITENS_CAIXAID, NEW.ITENS_SITUACAO, NEW.SAT_NUMEROCFE,
- NEW.SAT_SERIALSAT, NEW.ITENS_UN, NEW.ITENS_DESCVL, NEW.ITENS_DESCPERCENT, NEW.ITENS_CFOP, NEW.ITENS_CST, NEW.ITENS_NCM, NEW.ITENS_CEST,
- NEW.IMPOSTO_VPIS, NEW.IMPOSTO_PISCST, NEW.IMPOSTO_PISVBC, NEW.IMPOSTO_PISPPIS, NEW.IMPOSTO_COFINSCST, NEW.IMPOSTO_COFINSVBC,
- NEW.IMPOSTO_COFINSPCOFINS, NEW.INFADPROD, NEW.IMPOSTO_ICMSCST, NEW.IMPOSTO_ICMSPICMS, NEW.IMPOSTO_ICMSCSOSN,
- NEW.IMPOSTO_ICMSORIGDESC, NEW."IMPOSTO.ICMS.ORIG", NEW.CANCELITEM_VLCANC, NEW.IMPOSTO_TRIBDESC, NEW.TRANSF_BOOL, NEW.MARCA,
- NEW.GRUPO, NEW.SUBGRUPO, NEW.IDMARCA, NEW.IDGRUPO, NEW.IDSUBGRUPO, NEW.IDFORNECEDOR, NEW.FORNECEDOR, NEW.PDV_NUMERO, NEW.IBPX_TFNACIONAL,
- NEW.IBPX_TFIMPORTADO, NEW.IBPTX_ESTADUAL, NEW.IBPTX_MUINICIPAL)
- matching (ID,VENDA_NUMERO);
- END
- ^
- /* Trigger: ITENS_VENDA_BI */
- CREATE OR ALTER TRIGGER ITENS_VENDA_BI FOR ITENS_VENDA
- ACTIVE BEFORE INSERT POSITION 0
- AS
- BEGIN
- IF (NEW.id IS NULL) THEN
- NEW.id = gen_id(gen_itens_venda_id,1);
- END
- ^
- SET TERM ; ^
- /******************************************************************************/
- /*** Privileges ***/
- /******************************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement