Newbie Question I'm sure, but...
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Newbie Question I'm sure, but...

  1. #1
    Join Date
    Sep 2004
    Posts
    1

    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

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,095
    yes, a trigger would be the way to go. many, many examples at http://tahiti.oracle.com.
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  3. #3
    Join Date
    Sep 2004
    Location
    india
    Posts
    2
    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
  •  



Click Here to Expand Forum to Full Width