I have three databases connected remotedly via DBLink and I want to create a record in the three of them. The dynamic in this problem is that there is a company which has 3 retail stores in which they can sell items found in the others. The item1 is only found in retailstore1, item2 is only found in retailstore2 and so on. However, one store can sell items not currently found in it so it needs to request to the other stores in order to check if there's enough in stock. Everytime one store sells, it creates a record in LOG, but only if it was successful.
These are the tables used in the example.
- Retail Store #1: Items(a int), LOG(a int, b int, c int)
- Retail Store #2: Items(b int), LOG(a int, b int, c int)
- Retail Store #3: Items(c int), LOG(a int, b int, c int)
Now, I want to check if there's enough items in stock before making the record in LOG in the three stores, but this has to be done in a single query or store procedure or the necessary steps to make this possible. The restriction is that the databases need to be open once, execute, close and no more.