CREATE OR ALTER trigger ttbusuario_bi_b01d for tbusuario_bi
active before delete position 9
AS
DECLARE VARIABLE HISTORICO VARCHAR(500);
BEGIN

    HISTORICO = '';

    IF(OLD.USUARIO_ID is not null) THEN
    BEGIN
       HISTORICO = HISTORICO||'Painel do Qlik Sense: '||OLD.ID||' Excluido.';
    END

    IF(HISTORICO <> '') THEN
    BEGIN
       EXECUTE PROCEDURE SPI_HISTORICO('TBUSUARIO',OLD.USUARIO_ID, HISTORICO);
    END
END;