How can I run a Rigger that automatically updates a table when an attribute is updated?

Asked

Viewed 36 times

-1

Create OR Replace TRIGGER filme_log
before Update OF custo On filme
Referencing New As New Old As Old
For Each Row 
Begin 
Insert into filme_log Values(:new.nome_original, :old.custo, :new.custo, sysdate);
END;

This is my Rigger and this is working.

Begin
Update filme set custo = 9876546 where nome_original = 'UP';
Commit;
Declare
Cursor filme_log_cur is
Select nomeF,custo_old,custo_new, data
From filme_log;
nomeF_cur filme_log.nomeF%type;
custo_old_cur filme_log.custo_old%type;
custo_new_cur filme_log.custo_new%type;
data_cur filme_log.data%type;
Begin
Open filme_log_cur;
Loop Fetch filme_log_cur into nomeF_cur, custo_old_cur, custo_new_cur, data_cur;
EXIT WHEN filme_log_cur%notfound;
DBMS_Output.put_line('Dados inseridos em Filme_log:');
DBMS_Output.put_line(nomeF_cur || '  ' ||custo_old_cur || '  ' ||custo_new_cur || '  ' || data_cur);
END LOOP;
END;

And I’m trying to run this Rigger but I can’t understand why it’s not working.

  • João, you are in Stack Overflow in Portuguese, please translate your question.

  • Welcome to Stackoverflow in Portuguese. As the name implies, the Official language used here is English. So, can you Please Translate your Question? If you prefer, you may also Ask this same Question in the English Stackoverflow site.

  • Welcome to the Stackoverflow in Portuguese. As the name suggests, the official language used here is Portuguese. So, could you please translate your question? If you prefer, you can also ask the same question on Stackoverflow website in English.

  • Which database you are using?

  • We are using ORACLE.

1 answer

1

The problem may be that Trigger is disabled.

First check that Trigger is enabled using:

SELECT STATUS FROM USER_TRIGGERS WHERE TRIGGER_NAME = 'filme_log';

If disabled, enable using:

ALTER TRIGGER filme_log ENABLE;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.