Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exit trigger if condition is met

Status
Not open for further replies.

benjamenus

Programmer
Dec 3, 2001
157
GB
On my trigger I am inserting a value to a string. If the value = 'x' then I want the trigger to terminate without processing the rest of the code. However if it <> 'x' then I wish it to continue processing. What command can I do this with? It would be OK to use something like a label (VB) to move it to a line at the end of the trigger but I don't know if this is supported.

if sTest = 'x' then
UNKNOWN_COMMAND;
end if;

Some background:
To delete rows from a specific table (used by a bespoke application) it is neccessary to drop the trigger. I'm writing something in VB that will allow users to delete these rows but it is not an option to drop the trigger (or meet the trigger conditions). Therefore I need some way of bypassing this After Delete trigger. I'm assuming that I can't stop it firing, but can maybe exit it if conditions are met (as above). If you have any other ideas they'd be welcome.

Thanks
 
You might want to enclose your executable within a simple test:
BEGIN
IF my_value <> 'x' THEN
....
Do all of the processing
....
END IF;
EXCEPTION
....
END;
This way, if the value is 'x' the processing never gets started.

You could also use the WHEN clause to define whether or not the trigger should do anything:

CREATE OR REPLACE TRIGGER .........
WHEN (old.my_value <> 'x')
BEGIN
......
END;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top