Skip to content
Advertisement

Oracle trigger multiple conditions in when clause

I’m trying to create a trigger that updates a column in a table when other columns are updated. but getting the following error while saving the trigger

ORA-25000: invalid use of bind variable in trigger WHEN clause

My trigger is as follows, I’m not sure what is wrong with the code.

Advertisement

Answer

Although IF is an alternative to WHEN, I’d say that it is better to use WHEN clause whenever possible because it is a

SQL condition that must be satisfied for the database to fire the trigger

So, why would you even let the trigger fire and then conclude that oh, OK, I don’t want to do anything, after all? Better not running it at all!

Yes, WHEN clause has its restrictions and you can’t put anything you want in there, but – your case isn’t one of those.

(more info in Documentation, search for “WHEN clause”).

So, for a sample table

trigger would looks like this:

Testing:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement