Inserting with a Reader
Now let's suppose that the purchase table resides in an entirely different database from the sales, videos, and supplier tables. In this case, the data must be selected from one database into our application, then transferred from our application into the other database. With SourcePro DB, this is easy. Simply substitute the following code for //2-//4 in the previous example:
 
RWDBTable purchases = anotherDbase.table("purchase");
RWDBInserter insert = purchases.inserter(); //1
RWDBReader reader = select.reader(myConnection); //2
while(reader()) {
insert << reader; //3
insert.execute(anotherConnection); //4
}
On //1 an inserter is obtained for the purchase table, without supplying an argument. On //2 a reader for the previously constructed selector is declared, and on //3, the insertion operator is used to supply the inserter with data from the reader. When the inserter is executed on //4, the purchase table is populated with the current row from the reader. This time there are two database interactions:
*Rows are read into the application using myConnection with myDbase
*Rows are inserted using anotherConnection with anotherDbase.