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 >> Problem with triggers

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: Problem with triggers
 eiram  Posted: May 08, 2008 08:43:42 PM

 Total Post: 2
 Joined: May, 2008






 This is the first trigger that I'm making.
I'm trying to make a trigger to update only the field from the same row that is updated
when another field from the same row is updated. I'm doing something wrong.
Here is my code:

CREATE OR REPLACE TRIGGER MYSCH.APPT_RESCHEDULE
BEFORE UPDATE OF appointment
ON MYSCH.TBL_RESCHEDULE
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE

BEGIN
if ((:new.appointment > :old.due_date) or ((trunc(:new.appointment) = trunc(:old.due_date))
and to_char(:old.due_date,'HH24:MI:SS') < '13:00:00'))
and to_char(:new.appointment,'HH24:MI:SS') = '08:00:00'

update tbl_reschedule
set :new.due_date = to_date(to_char(:new.appointment,'DD-MON-YYYY')||' '|| '12:00:00',
'DDMON-YYYY HH24:MI:SS')
where pk_schedule_id := :old.pk_schedule_id;

else if ((:new.appointment > :old.due_date) or ((trunc(:new.appointment) = trunc(:old.due_date))
and to_char(:old.due_date,'HH24:MI:SS') < '17:00:00'))
and to_char(:new.appointment,'HH24:MI:SS') = '13:00:00'

update tbl_reschedule
set :new.due_date = to_date(to_char(:new.appointment,'DD-MON-YYYY')||' '|| '17:00:00',
'DD-MON-YYYY HH24:MI:SS')
where pk_schedule_id := :pk_schedule_id;
end if;

EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
NULL;
END MYSCH.APPT_RESCHEDULE;

Thank you for your help.

 Gitesh
Posted: May 09, 2008 02:14:35 AM  

 Total Post: 150
 Joined: May, 2005






 
When trigger was created that did you get any error?

 eiram
Posted: May 09, 2008 08:32:56 AM  

 Total Post: 2
 Joined: May, 2008






 
I don't get any erros. When I run the Trigger it shows me a prompt
asking me values to the OLD and NEW variables.

 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

  Mohammed Taj634
  Murtuja Khokhar586
  Jayanta Sur479
  Vigyan Kaushik385
  Ramesh Jois226
  neeraj sharma189
  snehalatha p166
  Gitesh Trivedi150
  Gopu Gopi138
  Kushal ratnaker136






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