0

I have created triggers over JDBC that doenot fire. I have checked its validity in the user_objects table and its valid and enabled. I tried creating trigger using the sqlplus console and it successfully fired, so where I could be going wrong? Any idea?

here is my trigger:

create or replace trigger t2 
after update of FIRST_NAME on QWERTY
referencing new as newv old as oldv
for each row
begin
 if  :oldv.FIRST_NAME != :newv.FIRST_NAME then 
insert into log values(user,sysdate,'QWERTY','FIRST_NAME',:oldv.FIRST_NAME,:newv.FIRST_NAME);
end if;
end;

I have tried execute(query) and executeUpdate(query) functions of Statement and tried PreparedStatement too but no luck yet.

Rishabh Kumar
  • 527
  • 4
  • 14
  • You created the trigger with `execute` and `executeQuery`, or an `update` after the trigger was created? Did you commit the update - can you see the updated values (and are you checking in a different session)? – Alex Poole May 11 '13 at 21:14
  • How exactly does the contents of the `query` variable look like? Please show us the full code. You can also query the `all_errors` view to check if you might have a syntax error in the SQL that you run through JDBC. –  May 11 '13 at 22:58
  • you cannt create trigger with executeQuery(), yes i did commit and can see the updated values...the problem is with JDBC, events are firing when i create triggers in sqlplus prompt and i haved checked for the validity of the trigger in the user_objects view and it is valid – Rishabh Kumar May 12 '13 at 08:27
  • It is definitely possible to create trigger through JDBC (otherwise JDBC tools like SQL Developer wouldn't even possible), so there must be something wrong with your **Java** code - which you still haven't shown us –  May 12 '13 at 09:48
  • thank you for your time .i am still learning .i figured that the log table was having number datatype that was not compatible with the string... – Rishabh Kumar May 12 '13 at 10:07

1 Answers1

0

You haven't considered null values in your code -- worth investigating, I'd think.

David Aldridge
  • 51,479
  • 8
  • 68
  • 96