Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 30th, 2004, 03:46 PM
pezibaer420 pezibaer420 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 pezibaer420 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Oracle - Trigger for delete, insert, update

Hi everyone,

I made the following trigger:

create or replace trigger deptneu_2_ins_upd_del
after update on deptneu_2
begin

if inserting then
dbms_output.put_line ('insert!');
end if;

if updating then
dbms_output.put_line ('upgedate!');
end if;

if deleting then
dbms_output.put_line ('delete!');
end if;
end;
/


but only if I update the table the trigger is working. What could be wrong?

Another question: if I change the attribute "location" the trigger should tell the old value as well as the new one? Could anyone tell me how to do that?

Thank you very much in advance!

Peter

Reply With Quote
  #2  
Old May 1st, 2004, 04:35 AM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,007 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 h 57 m 31 sec
Reputation Power: 67
You need to change

after update on deptneu_2

to

after update,insert,delete on deptneu_2

Quote:
the trigger should tell the old value as well as the new one?

use :new and :old variables to reference the two records.

E.g.

IF :new.location <> :old.location THEN
-- loction has changed
END;

Reply With Quote
  #3  
Old May 2nd, 2004, 02:00 PM
pezibaer420 pezibaer420 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 pezibaer420 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you very much, shammat!
Peter

Reply With Quote
  #4  
Old May 3rd, 2004, 04:24 PM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,007 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 h 57 m 31 sec
Reputation Power: 67
Just for the record: this is something that can easily be looked up in the manual

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle - Trigger for delete, insert, update


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT