Lesson 6: Sending data from the consolidated database to the remote database

In this lesson, data is replicated from the consolidated database(hq) to the remote database (field).

 Enter data at the consolidated database (hq) (Interactive SQL)
  1. If you are not currently connected to the consolidated database (hq), run the following command:

    dbisql -c "UID=DBA;PWD=sql;SERVER=server_hq;DBF=c:\tutorial\hq.db"
  2. Execute the following statements to add sample data to the SalesReps and Customers tables:

    INSERT INTO SalesReps ( rep_key, name )
    VALUES ( 'rep3', 'Example User' );
    
    INSERT INTO Customers ( cust_key, name, rep_key )
    VALUES ( 'cust3', 'Land Sports', 'rep1' );
    INSERT INTO Customers ( cust_key, name, rep_key )
    VALUES ( 'cust4', 'Air Plus', 'rep2' );
    COMMIT;
  3. Execute the following statements to confirm that the data has been entered:

    SELECT * FROM SalesReps;
    SELECT * FROM Customers;

To send the rows to the remote database (field), run the Message Agent on the consolidated database (hq).

 Send data from the consolidated database (hq) to the remote database (field)
  1. At the consolidated database (hq) run the Message Agent from the c:\tutorial directory:

    dbremote -c "UID=DBA;PWD=sql;SERVER=server_hq;DBF=c:\tutorial\hq.db"

    This command assumes that the consolidated database (hq) is currently running on the default server. If the database is not running, you must supply a DBF parameter with the database file name instead of the DBN parameter.

  2. When the Message Agent window displays Execution Completed, click Shutdown.

  3. Browse to c:\tutorial\field.

    A file named hq.0 is listed in the directory. This file contains the changes sent from the consolidated database (hq).