Home » RDBMS Server » Server Administration » How to insert into remote schema table
How to insert into remote schema table [message #54128] Thu, 31 October 2002 00:34 Go to next message
sai sreenivas jeedigunta
Messages: 370
Registered: November 2001
Senior Member
hello all,

I have two schema's say A and B in the same database.
In both of them , I have a table EMP with the same Structure .. .Now i want to write a Trigger to Insert a Record into B's EMP automativally whenever i Insert into A's emp..

Also please provide me the Syntax of Creating Database link for the above scenario if they are necessary..

Thanks and Regards
sai
Re: How to insert into remote schema table [message #54135 is a reply to message #54128] Thu, 31 October 2002 06:10 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
SQL> connect scott/tiger
Connected.
SQL> grant insert on scott.dept to mag;

Grant succeeded.

SQL> connect mag/mag
Connected.
SQL> create or replace trigger trigger_t1
  2  after insert on dept
  3  for each row
  4  begin
  5  insert into scott.dept values (:new.deptno,:new.dname,:new.loc);
  6  end;
  7  /

Trigger created.

SQL> select * from dept;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

SQL> select * from scott.dept;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

SQL> insert into dept values
  2  (50,'GENOME','CHarles');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from scott.dept;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
        50 GENOME         CHarles

SQL> select * from dept;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
        50 GENOME         CHarles

Re: How to insert into remote schema table [message #54138 is a reply to message #54135] Thu, 31 October 2002 10:44 Go to previous message
sai sreenivas jeedigunta
Messages: 370
Registered: November 2001
Senior Member
Thanks a lot Mahesh... I am going to Check it out..
Previous Topic: problem creating database link...
Next Topic: ORA-24327
Goto Forum:
  


Current Time: Fri Dec 27 13:30:19 CST 2024