Table comparison utility: TBCOMP (DK1TCOMP)

The tableBASE Comparison (TBCOMP) program compares tables and identifies any differences for review. Tables are considered unequal if their definitions are significantly different or if any of the rows do not match.

Note:
TBCOMP is used extensively to upgrade to a new release of tablesONLINE.

Not all items in a table definition are compared. The following items are compared:

  • SEARCH-METHOD
  • ORGANIZATION
  • INDEX
  • STORAGE-MODE
  • ROW-SIZE
  • KEY-LOCATION
  • KEY-SIZE
  • EXPANSION-FACTOR
  • LOW-DENSITY
  • HIGH-DENSITY
  • table contents

Rows are considered unequal if any part of the row does not match.

The TBCOMP program is driven by statements contained in a card image input file. Two input lines are required to specify each pair of tables to be compared. Each table is defined on a separate input statement, as listed in Table 99. The fields on each input statement must be given in a specific order with each field separated by one or more blanks or a comma.

Table 99. Input statement

Field

Description/comments

Command

Command may be COMPARE or CM

Comments

Comments follow an asterisk (*) in column 1

Table

New or old table to be compared

Library DDNAME

DDNAME of library where table resides

Read password

Read password of table, if any

Generation

Generation of table

View

View containing formatting information for table

Unload DDNAME

DDNAME defining a flat file where the difference table(s) is to be unloaded

The Command must start in column 1. An asterisk (*) in column 1 indicates a comment. TBCOMP ignores comment lines. The mandatory fields in each statement are:

  • Command
  • Table
  • Library DDNAME

The Unload DDNAME must reference a sequential file or member of a PDS.

TBCOMP analyzes the differences between tables by treating the first table as the new table and the second table as the old table. It generates the differences required for making the changes to the second table, to be identical to the first.

From the example above, you can see that when you first apply the DELETE set to TBL02, followed by the UPDATE set also to TBL02, you will have the identical contents as TBL01.

TBCOMP can report the differences in any of three formats:

  • two printed reports
  • two flat files
  • two difference tables

TBCOMP does not change any of the tables that it analyzes. Tables are changed by:

  • inspecting the printed report and editing tables manually
  • using the unload files as input to TBEXEC
  • writing your own program to read the difference tables or the unload files

Using the printed reports allows for the inspection of each change to ensure that it is correct for the system.

Using the unload files is the simplest method to apply changes to a table. This is described in the next section.

The rows in difference tables are identical in format to the rows in the unload files except that they are stored in tableBASE libraries.

A report is always printed containing the results of each comparison, which is summarized on one line showing table and library names, generation numbers, result code for the comparison, and a brief description, as listed in Table 100.

Table 100. Result codes

Result code

Meaning

0

Contents and definitions match

37

Definitions do not match (a list of mismatched definition fields is given)

100

Definitions match but contents differ

n

Other values are error codes from tableBASE—for example, invalid password

TBCOMP will issue one of the return codes listed in Table 101.

Table 101. Return codes

Return code

Meaning

0000

All pairs of tables are the same (with the possible exception of some acceptable parts of the definition)

0008

The contents or definitions of at least one pair differ

Sample tables comparison job with JCL follows:

The EXEC card PARM values are:

  • P is a flag indicating whether to print the differences (value P or Y) or not (leave empty). This is optional. The default is to not print differences.
  • S is a flag indicating whether to create difference tables (value S or Y) or not (leave empty). This is optional. The default is to not create the difference tables.
  • UPDT and DELE are prefixes for difference table names when difference tables are to be created. TBCOMP will build the names of the difference tables by appending as many of the last non-blank characters in the names of the tables being compared as possible to these prefixes. (Table names may not exceed eight characters). This is optional. The defaults are UPDT and DELE. For example, if you coded U2 and D3 for UPDT and DELE respectively and the name of both tables being compared is TABLE123, the DELETE difference table name would be named D3BLE123 and the UPDATE table would be named U2BLE123.
  • nnnnnn is the master password. This is optional. There is no default.
  • N is a flag indicating that the data content comparison is not case sensitive. Uppercase or lowercase is ignored in the test for equality. The default value is Y. The comparison is case sensitive.

The file specified by TBCMPRPT contains a summary of the differences found.

The COMPARE command provides for the optional parameter to specify a View which contains the formatting information for this table. If you do not specify this View name, the list of differing rows will be contained in the file specified by TBCMPLST. If the View name is specified, the file specified by TBREPORT will contain the list of differing rows and the file specified by TBLOG will contain a summary of the tables.

The sample job compares three pairs of tables.

  • Example 1 compares specific generations of TABLE1. Any differences will be printed using the formatting information in the corresponding Views. The read passwords in this case are redundant since the master password is supplied on the EXEC card. The difference tables are unloaded to members of *YOUR.PDS*. Difference tables UPDTBLE1 and DELEBLE1 will be stored on NEWLIB1.
  • Example 2 compares the latest generation of TABLE2 and TABLE3. The master password will be used to open the tables if they are read-protected. Any differences will be printed without formatting. Difference tables UPDTBLE2 and DELEBLE3 will be stored on NEWLIB1. The difference tables are not unloaded to unload files.
  • Example 3 compares the latest generations of TABLE4. The master password will be used to open the tables if they are read-protected. Any differences will be printed using the formatting information in the corresponding Views. Difference tables UPDTBLE4 and DELEBLE4 will be stored on NEWLIB2. The difference tables are not unloaded to unload files.