Home » SQL & PL/SQL » SQL & PL/SQL » After triggers
After triggers [message #2994] Wed, 28 August 2002 11:05 Go to next message
Gaurang
Messages: 4
Registered: August 2002
Junior Member
consider the following example:

create trigger update_qty
after /*insert or delete or update operations
will take place before the trigger is
is fired */

insert or update of qty or delete on items
for each row
begin
if inserting then
update parts
set onhand_qty := onhand_qty - :new.qty
where id = :new.part_id;
elsif ........
.............
..............
......
end;

/* i would like to terminate insert or delete or update transactions if some condition evaluates to false in Begin ..... End block [[trigger action body]]
i.e. there should be no updates on the table */
Re: After triggers [message #2998 is a reply to message #2994] Wed, 28 August 2002 13:17 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
To abort the DML, just raise an error:

if not some_condition then
  raise_application_error(-20000, 'Invalid item transaction');
end if;
Previous Topic: nested sql help
Next Topic: special characters
Goto Forum:
  


Current Time: Tue Apr 23 16:40:16 CDT 2024