ALTER TABLE TBCHEQUE
    ADD PDV_CFE_ID INTEGER DEFAULT 0 NOT NULL;


SET TERM ^ ;

CREATE trigger ttbcheque_pdv_b01d for tbcheque_pdv
active before delete position 1
AS
BEGIN
    IF(OLD.VALOR <> OLD.SALDO) THEN
    BEGIN
        EXCEPTION "..."'CHEQUE COM LANCAMENTOS VINCULADOS. EXCLUSAO NAO PERMITIDA';
    END ELSE
    BEGIN
        DELETE FROM TBCHEQUE_PDV_ITEM T WHERE T.CHEQUE_PDV_ID = OLD.ID;
    END
    
END
^

SET TERM ; ^


ALTER TABLE TBCHEQUE_PDV
    ADD ESTABELECIMENTO_ID INTEGER DEFAULT 0 NOT NULL;

ALTER TABLE TBCHEQUE_PDV
    ADD QTD_PARCELAS INTEGER DEFAULT 0 NOT NULL;


ALTER TABLE TBCHEQUE_PDV
    ADD DATA_BASE DATE;

