Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> about triger

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: about triger
 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&regards
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

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Vinoth Kumar363
  Gopu Gopi340
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software