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 July 9th, 2004, 03:16 PM
Lindbird Lindbird is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 Lindbird User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Starting with Triggers

Hello,
I have never writen a trigger before and need some advice. I have two tables and when data is inserted into table A then I need to insert the same data into table B along with the time.

create or replace trigger shadowDepts
after insert on depts
begin
insert into depts_shadow values(deptno,dname,sysdate)
end;
/

except deptno and dname are the values of what was inserted into the original Table A.
How do I access those values... I tried using ":new" but it gave me an error, I think because it is not a "for each row" trigger.

Please let me know where I am going wrong,
Thanks,
Ryan

Reply With Quote
  #2  
Old July 9th, 2004, 07:27 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 6
try that:

create or replace trigger shadowDepts
after insert on depts
for each row
begin
insert into depts_shadow values(:new.deptno,:new.dname,sysdate);
end;
/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Starting with Triggers


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 2 hosted by Hostway
Stay green...Green IT