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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 9th, 2004, 06:58 PM
JavaKavaGuy JavaKavaGuy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 JavaKavaGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Trigger Help - Trying to Auto Insert...

Trying to auto insert the newest records from one table into another Table.

I have a vendor provided table that is part of my database (running Oracle 9i) so I can't change the underlying structure to it or their process stops fluxing. However, I can add a trigger to it. What I want to do is this:

When the vendor's software inserts a new row (through their own automated process) I want to insert data from that same new record into another table of my own. (where of course I can re-format it, etc., and make the data my own)

The original vendor table does not have a insertion timestamp field to work off of.

What is the best way to trigger an insert off the latest inserted record? It works to replace all the records in the entire vendor table but I only want to insert one record at a time.

Any help you can provide would be appreciated.

Reply With Quote
  #2  
Old March 26th, 2004, 10:11 AM
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: 5
Just look at the following example:

CREATE OR REPLACE TRIGGER emp_Ins_Upd_Del_Tr
BEFORE DELETE or INSERT or UPDATE
ON emp
FOR EACH ROW
BEGIN
if UPDATING then
UPDATE emp_temp
SET sal = :new.sal
, comm = :new.comm
WHERE empno = ld.empno;
end if;
if DELETING then
DELETE FROM emp_temp
WHERE empno = ld.empno;
end if;
if INSERTING then
INSERT INTO emp_temp
VALUES ( :new.empno
,:new.ename
,:new.job
,:new.mgr
,:new.hiredate
,:new.sal
,:new.comm
,:new.deptno
);
end if;
end;
/


Regards

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Trigger Help - Trying to Auto Insert...


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 4 hosted by Hostway