I need to create a trigger that fires whenever I have an insert event in the table, before it is inserted, it checks a condition, if the condition is respected it changes the value of a certain field that is being inserted.
Example:
-- id do registro atual que esta sendo inserido
if id_pai = 0 or null
-- ela pega este ID, faz um select em outra tabela ( select id from tabela2 where id_nota = id_nota.
-- pega o resultado que seria o ID do registro da tabela2 e insere no campo
-- id_pai do registro que esta sendo inserido.
end;
I have been researching some models like build the trigger, however, I do not know how to work on the issue of manipulating the field being inserted, and change the value.