Tracking changes with IBConsole

From InterBase

Go Up to Change Views Quick Start


For the following examples you need two users: SYSDBA which is a default user on InterBase and HRMANAGER you'll need to create this user and grant it all required permissions.

Example 1: Seeing Changes on wisql

This is a basic example on how to see changes on a table using the Interactive SQL Window (wisql).


Initializing your subscription

Use a SELECT query to set a starting point for your subscription, you only need to this the first time you set the subscription.

  1. Launch IBConsole
  2. Connect to the employee database as HRMANAGER.
  3. Click on the "Interactive SQL" window icon Isql icon.png.
  4. On the "Interactive SQL" window paste the following code:
    SET SUBSCRIPTION sub_employee_changes ACTIVE;
    -- Query all the salaries for Engineering employees, their job grade, country, and salary: 
    SELECT job_code, job_country, job_grade, salary FROM employee WHERE job_code='Eng';
    
  5. Click on "Execute Query" InteracSQLexecute.png or press F5.
  6. You should see a list of records similar to:
    Ib con sub records.png
  7. Press F9 to commit.

Updating Data

Next, using the isql console modify records on the 'employee'. Make the changes using a different user otherwise you won't be able to see them.

  1. Start the isql console.
  2. Connect to the employee database as SYSDBA.
  3. Update all the engineering salaries with a job grade of 4 and located in the USA:
    UPDATE employee SET salary = salary + salary * 0.0125 WHERE job_grade=4 AND job_country = 'USA';
    
  4. Commit your changes.
    commit;
    

Seeing the Changes

The Interactive SQL window lists all the changes on the employee database and it also shows which records were modified.

  1. Go back to the "Interactive SQL" window.
  2. Clear any previous code and paste the following code:
    SET SUBSCRIPTION sub_employee_changes ACTIVE;
    -- Query all the salaries for Engineering employees, their job grade, country, and salary: 
    SELECT job_code, job_country, job_grade, salary FROM employee WHERE job_code='Eng';
    
  3. Click on "Execute Query" InteracSQLexecute.png or press F5.
  4. You should see a list of modified records.
    Mod records ibconsole.png
    All modified records have a circle next to them.
  5. Press F9 to commit.

Example 2: Seeing Different Changes

In this example you can see how IBConsole shows different kinds of changes.

Initializing your Subscription

Use the SELECT queries to set a starting point for your subscriptions, you only need to this the first time you set the subscription.

  1. Launch IBConsole
  2. Connect to the employee database using the HRMANGER user.
  3. Click on the "Interactive SQL" window icon Isql icon.png.
  4. On the "Interactive SQL" window paste the following code:
    SET SUBSCRIPTION sub_employee_changes AT 'device_2' ACTIVE;
    SELECT emp_no, dept_no, job_code, job_country FROM employee WHERE job_country='England';
    
  5. Click on "Execute Query" InteracSQLexecute.png or press F5.
  6. You should see a list of records.
    Records example2.png
  7. Press F9 to commit.

Updating Data

Using the isql console modify records on the 'employee'. Make the changes using a different user otherwise you won't be able to see them.

  1. Start the isql console.
  2. Connect to the employee database as SYSDBA.
  3. Move employee "28" from department 120 to department 621:
    UPDATE employee SET dept_no=621 WHERE emp_no=28;
    
  4. Commit your changes:
    commit;
    
  5. Next, add a new entry to the database:
    INSERT INTO EMPLOYEE (EMP_NO, FIRST_NAME, LAST_NAME, PHONE_EXT, HIRE_DATE, DEPT_NO, JOB_CODE, JOB_GRADE, JOB_COUNTRY, SALARY) VALUES (147, 'John', 'Smith', '223', '10/20/2014 00:00:00', '621', 'Eng', 4, 'England', 39211);
    
  6. Commit your changes:
    commit;
    

Seeing the Changes

  1. Go back to the IBConsole.
  2. On the "Interactive SQL" window paste the following code:
    SET SUBSCRIPTION sub_employee_changes AT 'device_2' ACTIVE;
    SELECT emp_no, dept_no, job_code, job_country FROM employee WHERE job_country='England';
    
  3. Click on "Execute Query" InteracSQLexecute.png or press F5.
  4. You should see a list of modified records.
    Mod records example2.png
    Additions are marked in green and modifications in yellow.
  5. Press F9 to commit.

See Also: