/******************************************************************************/
/***               Generated by IBExpert 27/07/2022 17:22:27                ***/
/******************************************************************************/

/******************************************************************************/
/***      Following SET SQL DIALECT is just for the Database Comparer       ***/
/******************************************************************************/
SET SQL DIALECT 3;



/******************************************************************************/
/***                                 Tables                                 ***/
/******************************************************************************/

CREATE GENERATOR PQ_CADPROMOCAODET;

CREATE TABLE CADPROMOCAODET (
    ID           INTEGER NOT NULL,
    IDPRODUTO    INTEGER,
    CODPRODUTO   VARCHAR(20),
    VALOR        NUMERIC(14,2),
    PORC_DESC    NUMERIC(14,2),
    VALORPROMOCAO NUMERIC(14,2),
    DATACAD      DATE,
    DATAINICIAL  DATE,
    DATAFINAL    DATE,
    IDPROMOCAO   integer, 
    CONTROLE     VARCHAR(20)
);




/******************************************************************************/
/***                              Primary keys                              ***/
/******************************************************************************/

ALTER TABLE CADPROMOCAODET ADD PRIMARY KEY (ID);


/******************************************************************************/
/***                                Triggers                                ***/
/******************************************************************************/



SET TERM ^ ;



/******************************************************************************/
/***                          Triggers for tables                           ***/
/******************************************************************************/



/* Trigger: INSCADMETAS */
CREATE OR ALTER TRIGGER INSCADPROMOCAODET FOR CADPROMOCAODET
ACTIVE BEFORE INSERT POSITION 0
AS
begin
NEW.ID=GEN_ID(PQ_CADPROMOCAODET,1);
end
^

SET TERM ; ^



/******************************************************************************/
/***                               Privileges                               ***/
/******************************************************************************/


