SET TERM ^ ;

CREATE OR ALTER trigger ttbocorrencia_web_freed_b02i for tbocorrencia_web_freed
active before insert position 0
AS
DECLARE VARIABLE HISTORICO VARCHAR(500);
BEGIN

    HISTORICO = new.id||' - Feed Incluido';

    IF (HISTORICO <> '') THEN
    BEGIN
        EXECUTE PROCEDURE SPI_HISTORICO('TBOCORRENCIA_WEB',new.ocorrencia_web_id, HISTORICO);
    END

END
^

SET TERM ; ^

SET TERM ^ ;

CREATE OR ALTER trigger ttbocorrencia_web_freed_b01d for tbocorrencia_web_freed
active before delete position 0
AS
DECLARE VARIABLE HISTORICO VARCHAR(500);
BEGIN

    HISTORICO = '';

    IF ( OLD.id > 0) THEN
    BEGIN
        HISTORICO = HISTORICO||old.id||' - Feed Excluido';
    END

    IF (HISTORICO <> '') THEN
    BEGIN
        EXECUTE PROCEDURE SPI_HISTORICO('TBOCORRENCIA_WEB',old.ocorrencia_web_id, HISTORICO);
    END
end
^

SET TERM ; ^

