-
Newbie Question I'm sure, but...
I'm very new to Oracle and I'm really looking for a quick answer. I would also appreciate an example of how to do this, but...
My problem is that I want to be able to create a new record in TableB when a new record is created in TableA. In other words, automated synchronization of the two tables, but I need to be able to select certain fields from TableA and be able to add new fields for entry into TableB at the same time. Here's my example...
A new record in TableA is created on 9/24/2004 10:04:01AM as such:
EmplID First Last Dept
000001 Bob Saucier Sales
I need to create a new record in TableB with the following:
EmplID First Last Date
000001 Bob Saucier 9/24/2004
Hopefully I've explained this well enough that someone could help me out. Will a trigger work in this case or is there a better way? And how do I do it?
Thanks!
Bob
-
yes, a trigger would be the way to go. many, many examples at http://tahiti.oracle.com.
Jeff Hunter
-
take this example >>>>>
consider you had a table created as follows:
CREATE TABLE abc
(empid number(4), ename varchar2(20));
We could then create a BEFORE INSERT trigger as follows:
CREATE OR REPLACE TRIGGER abc_before_insert
BEFORE INSERT
ON abc
FOR EACH ROW
DECLARE
BEGIN
/*u can keep audit of the same table by */
INSERT INTO Audit (eid, OldValue, NewValue) VALUES (
eid, :OLD.eid, :NEW.eid);
END;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|