SET TERM ^ ;

CREATE OR ALTER trigger ttbregistro_orcamento_item_b09d for tbregistro_orcamento_item
active before delete position 9
AS
declare variable HISTORICO VARCHAR(500);
begin
    HISTORICO = '';

    IF(OLD.ID > 0) THEN
    BEGIN
        HISTORICO = 'MODELO: '||OLD.MODELO_DESCRICAO||', COR '||OLD.COR_DESCRICAO||', TAM'||OLD.TAM_DESCRICAO||' EXCLUIDO;';
    END

    IF(HISTORICO <> '') THEN
    BEGIN
        EXECUTE PROCEDURE SPI_HISTORICO('TBREGISTRO_ORCAMENTO', OLD.ORCAMENTO_ID, HISTORICO);
    END
end
^

SET TERM ; ^

