|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Trigger Help - Trying to Auto Insert... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|