2
votes

I have two oracle 11g databases. I have a table TASKS in DB1(in a schema) and another table ORDERS in DB2(in a schema). Whenever a new order with(OrderID and OrderStatus) is created in ORDERS table i need to create a new task in TASKS table(with TaskID as OrderID and TaskStatus as OrderStatus). When a user updates TaskStatus in TASKS table Order Status for its order in ORDERS table should get updated. I have a DBLink created in DB1 to access ORDER table in DB2.

To implement this requirement am planning to have a two triggers. First trigger on ORDERS table to insert a new Task in TASKS table whenever a new order is created. Second trigger on TASKS table to update Order Status in ORDERS table whenever there is a task status change in TASKS table.

My Concern is this trigger solution works only if two DBs are up. Whenever DB1 is down and a new order is created in DB2 this solutions fails to insert a new Task in DB1. I think instead of creating First trigger on ORDERS table we can create this trigger on a VIEW created in DB1 for ORDERS table in DB2. This solution to create VIEW in DB1 solves the problem of inserting a new TASK in TASKS table when DB1 is down. I think this solution of creating a view on TASKS table for task status change will not work as both view and table are in same DB1.

Is there any better approach for this problem? Please help.

1
I don't understand how a view can solve your problem. If the db is down you have two options : 1. when it goes up - sync the entire table against the tasks table in the other db. 2. keep a queue and once the other db is up, bulk insert what ever piled up. - haki
@haki -- I just browsed some solutions and found there is a way to solve this problem by creating Materialized views. Even i am not sure how it works. Actually am looking for a better alternate solution.Thanks - Ramkumar
There is a big difference between views (as you wrote in your post) and materialized views. - haki
I think having all related data in the same database is a better approach. - Dan Bracuk

1 Answers

0
votes

Triggers are a valid solution to this problem. How often are the dbs likely to be down in reality. As mentioned above advanced queueing can be use to solve this of problem. I am assuming that you don't have any control over the creation of databases in this way. It seems like they should be in the same schema or at least running against the same instance?

http://docs.oracle.com/cd/B10501_01/appdev.920/a96587/qintro.htm