SET TERM ^ ;

CREATE OR ALTER trigger ttbcheque_pdv_b01u for tbcheque_pdv
active before update position 1
AS
BEGIN
    IF(NEW.SALDO <> OLD.SALDO) THEN
    BEGIN
        IF(NEW.SALDO = 0) THEN
        BEGIN
            NEW.STATUS = 2;
        END

        IF(NEW.SALDO > 0) THEN
        BEGIN
            NEW.STATUS = 1;
        END

    END
END
^

SET TERM ; ^

