Home > Ask the Oracle Database / Applications Experts > Oracle database backup and recovery Questions & Answers > Updating data in remote database when local database is updated
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Updating data in remote database when local database is updated

Brian Peasland1 EXPERT RESPONSE FROM: Brian Peasland1

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 12 November 2004
I do not know how to update the database remotely while I am entering data on another remote area of the database. In short, there two databases, one with Oracle 8i and one with Oracle 9i, at two different locations. At one location, one person enters data through the SQL form. The database at the other location, which is remote, should be automatically updated with the same record. Please give me details that I can understand easily.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Oracle database backup and recovery
Can I perform an Oracle server backup through a client machine?
How to execute DML in an Oracle trigger with EXECUTE IMMEDIATE
How to restore a dump file with the Oracle SHOW=Y option
Why do I get an Oracle not available error with Oracle 8i on Windows?
How to perform Oracle database recovery with a corrupt online redo log
Can I create an Oracle Catalog Database with the Enterprise Console?
Do I need to recreate views after an Oracle table reorg?
Client-based apps vs. web-based apps in Developer 2000
How to perform an Oracle 8i to 10g migration
Can I move the tablespace online with missing datafiles in Oracle?

Oracle database backup and recovery
Can I perform an Oracle server backup through a client machine?
How to execute DML in an Oracle trigger with EXECUTE IMMEDIATE
How to restore a dump file with the Oracle SHOW=Y option
Why do I get an Oracle not available error with Oracle 8i on Windows?
Oracle tutorial library: SearchOracle.com's learning guides
How to perform Oracle database recovery with a corrupt online redo log
Can I create an Oracle Catalog Database with the Enterprise Console?
Do I need to recreate views after an Oracle table reorg?
Client-based apps vs. web-based apps in Developer 2000
How to perform an Oracle 8i to 10g migration
Oracle database backup and recovery Research

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


The first thing you need to do is to create a database link pointing to the other location. The database link can be created with a command similar to the following:

CREATE DATABASE LINK other_db CONNECT TO scott IDENTIFIED BY tiger
USING 'tns_alias';

You'll want to give the database link a better name, use the appropriate userid/password to connect to the remote database, and configure your TNSNAMES.ORA file with a TNS alias to point to that database. You can test the database link with a simple query like the following:

SELECT sysdate FROM dual@other_db;

The "@other_db" clause uses the database link you created. If the query returns the date, then the link works properly. Once the link is set up, you can either issue a command to modify the data in the remote database when you modify the local database, or you can use a database trigger. For instance, if the application modifies the local database by performing an INSERT similar to the following,

INSERT INTO my_table VALUES (1,'Two');

then you can also code another SQL statement to insert the same values across a database link.

INSERT INTO my_table@other_db VALUES (1,'Two');

Additionally, you can create a trigger:

CREATE TRIGGER modify_remote_my_table
BEFORE INSERT ON my_table
BEGIN
  INSERT INTO my_table@other_db VALUES(:new.colA, :new.colB);
END;
/

You can write similar triggers for updating and deleting rows as well.




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts