| raj |
Posted: Aug 17, 2008 04:32:27 AM |
Total Post: 2
Joined: Aug, 2008
|
| How to stop any DML statment through TRIGER useing When claues. |
|
|
puri |
| Posted: Aug 18, 2008 02:15:09 AM | |
|
Total Post: 18
Joined: Jul, 2008
|
hi raj,
when clause is valid only for row-level triggers only.body of the trigger will be executed only for those rows that meet the condition specified by the when clause.
for e.g.
create or replace trigger <trigger_name>
before insert or update of <column_name> on <table_name>
for each row when (new.column_name > condition)
begin
trigger body
end.
i don't know whether this is the answer u want. let me know
thanks®ards
puri
|
|
|
|
|
raj |
| Posted: Aug 18, 2008 04:26:38 AM | |
|
Total Post: 2
Joined: Aug, 2008
|
Thanks but my question was:
take one example : lets assume that written a trigger for update .
If when clause meet the condition then how to write trigger body so that we can stop to execute update statment ( for which this trigger ).
|
|
|
|
|
dipali |
| Posted: Aug 20, 2008 09:19:15 AM | |
|
Total Post: 35
Joined: Dec, 2006
|
You can do it by creaing "Before" trigger and raising exception using "raise_application_error" statement according to your business requirements.
Consider following example for reference:
SQL> create or replace trigger emp_biu
2 before insert or update on employee
3 referencing new as new old as old
4 for each row
5 begin
6 if nvl(:new.salary,0) >= 10000 then
7 raise_application_error (-20999,'Salary with
8 commissions should be less than 10000');
9 end if;
10 end;
11 /
Regards,
Dipali..
|
|
|
|
|
Vish |
| Posted: Aug 24, 2008 04:53:05 AM | |
|
Total Post: 129
Joined: Jan, 2007
|
You can do one more thing that
you can check the conditions before doing any DML operation.
ie..
IF new.ABC <your condtion> then
if true then
your DML statement.
Endif
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |