Results 1 to 5 of 5

Thread: Please help me

  1. #1
    Join Date
    Apr 2004
    Posts
    10

    Question Unanswered: Please help me

    Hi All,
    I want to write an application to replication data in a database to other. But
    I don't know how to capture all data change in a table when users insert, update or delete rows. Can I use Java to do it? Please help me.
    yancancook

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    You could use database triggers (check the Oracle documentation about them); here's just an example to illustrate what you could do using shuch a trigger. You should, of course, write code to perform job you need.
    PHP Code:
    CREATE OR REPLACE TRIGGER TSK_SUS_AFTER_IUD
    AFTER DELETE 
    OR INSERT OR UPDATE ON TSK_STAVKE_UTUZENJA_STECAJA
    FOR EACH ROW
     
    BEGIN
     
    IF DELETING THEN
     
    UPDATE TSK_UTUZENJA_STECAJEVI
         SET GLAVNICA 
    GLAVNICA - :OLD.IZNOS
         WHERE US_ID 
    = :OLD.US_ID;
     
    ELSIF INSERTING THEN
     
    UPDATE TSK_UTUZENJA_STECAJEVI
         SET GLAVNICA 
    GLAVNICA + :NEW.IZNOS
         WHERE US_ID 
    = :NEW.US_ID;
     
    ELSIF UPDATING THEN
     
    UPDATE TSK_UTUZENJA_STECAJEVI
         SET GLAVNICA 
    GLAVNICA - :OLD.IZNOS + :NEW.IZNOS
         WHERE US_ID 
    = :OLD.US_ID;
     
    END IF;
     
    END TSK_SUS_AFTER_IUD

  3. #3
    Join Date
    Sep 2003
    Location
    Virginia, USA
    Posts
    246
    Replication is a free feature of all supported versions of Oracle Enterprise Edition (817, 920, 10g). Check it out; I really like it. There are also log scraper programs like Quest Shareplex and Datamirror iReflect, which capture redo log entries and apply them to the remote database - and unlike Oracle Standby Database these two programs allow all of your databases to be open in read/write mode.

    If your "other" database is not Oracle, you can use Oracle Gateways to treat them like Oracle databases. For example, you can setup replication between Oracle and DB2, but if you want multi-master then the DB2 database must be version 8 or higher.
    MarkRem
    Author, Oracle Database 10g: From Nuts to Soup
    http://www.remidata.com/book_nuts2soup.htm

  4. #4
    Join Date
    Jan 2003
    Location
    China
    Posts
    38
    Littlefoot:
    Can we do something on other database in trigger?
    Can you insert a row to a SQLServer table in an Oracle trigger?
    Fan Yi

  5. #5
    Join Date
    Sep 2003
    Location
    Virginia, USA
    Posts
    246
    Yes. Look at Oracle's gateway products, also known as Heterogeneous Services. A trigger in Oracle can insert into Sybase, SQL Server, DB2, and other databases. You can also select (fetch) data back from SQL Server to Oracle.

    I am not sure if the Gateway can be used to push data from SqlServer to Oracle. I've always used Oracle to control push and pull operations; never used SqlServer to control the transmission of data to Oracle.
    MarkRem
    Author, Oracle Database 10g: From Nuts to Soup
    http://www.remidata.com/book_nuts2soup.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •