SET TERM ^ ;

CREATE OR ALTER trigger ttbcor_b987iud for tbcor
active before insert or update or delete position 987
AS
declare variable modelo_id integer;
begin
    if(inserting)then execute procedure spi_integracao_mobile('TBCOR',new.codigo,'I');
    if(updating )then execute procedure spi_integracao_mobile('TBCOR',new.codigo,'A');
    if(deleting )then execute procedure spi_integracao_mobile('TBCOR',old.codigo,'D');


    if(inserting or updating)then
    begin
        for
            select
                c.modelo_id
            from tbmodelo_cor c
            where c.cor_id = new.codigo
        into
            :modelo_id
        do begin
            if(inserting)then execute procedure spi_integracao_api('TBMODELO',modelo_id,'I');
            if(updating )then execute procedure spi_integracao_api('TBMODELO',modelo_id,'A');
        end
    end
end
^

SET TERM ; ^

