Comparing DB2 Tables/Views

#### Search Results

Search

# Comparing DB2 Tables/Views

This document covers the following topics:

- Prerequisites and Restrictions for DB2 Tables/Views

- Calling the Function: Compare DD Objects with DB2 Files

- Parameters for DB2 Tables/Views

- Comparing DB2 Tables and Views in Batch Mode

## Prerequisites and Restrictions for DB2 Tables/Views

DB2 must be installed. See the section DB2 and SQL/DS in the Predict and Other Systems documentation.

See also General Prerequisites for Comparison Functions.

## Calling the Function: Compare DD Objects with DB2 Files

The Compare DD Objects with DB2 Files screen is called with code C and object code T2 in any Predict main menu or with the command `COMPARE TABLE`.

    18:06:57             *****  P R E D I C T  *****              2007-05-31
    Plan   0           - Compare DD Objects with DB2 Files -         Profile SYSTEM

    File ID ...........                                  Files of type ..*
    Contained in DA ...
    SQL Server .......*                                  <Default Server>

    Check options                       List options
      File attributes .... Y (Y/N)        Files .........................* D
      Fields ............. Y (Y/N)        Fields ........................* D
                                          Members using differences .....* N
    Update options
      File attributes .... N (Y/N)
      Field sequences .... N (Y/N)
      Add fields ......... N (Y/N)
      Purge fields ....... N (Y/N)
      Field attributes ... N (Y/N)

    Restrictions ........*   Profile Default ,used        Save set ....... N (Y/N)

    Command ===>
    Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
          Help  Next  Stop  Last  LnkEl Flip  Print Impl  AdmFi SelFi Prof  Main

## Parameters for DB2 Tables/Views

Common parameters which are not included in the table below are described under Common Parameters for All DB2 Types.

Parameters
Selection criteria
File ID | The ID of the Predict file object or objects which are to be compared with the connected DB2 tables or views. Asterisk notation can be used.
Files of type | Limit the function to files of the specified type.
Contained in DA | Limit the function to tables and views which reside in the specified database of type D. Asterisk notation can be used.
Check options
If check options are not set, compare functions will not reset the Modified after generation flag. See Resetting the Modified after generation Flag for more information.
File attributes |
Y | Attributes of the file are to be compared with the implementation of the file in DB2.
Fields |
Y | The field list of the file object is to be compared with the DB2 table or view.
List options
Files |
How attributes of the Predict file object are to be displayed.
Y | All file attributes.
N | No file attributes.
D | Different: only file attributes whose Predict values differ from the implementation.
Fields |
How fields linked to the Predict file object are to be displayed.
Y | All fields.
N | No fields.
D | Different: only fields whose Predict definitions differ from the DB2 table or view.
Members using differences |
Determines the amount of information to be displayed on members using fields that have been compared and whose Predict definition differs from the DB2 table or view.
Y | Display the names and types of all members.
N | Do not display members.
C | Count the number of members per library.
Update options
File attributes |
Y | Attributes of the Predict file object and, for files of type E, the subselect specification of the SQL create statement are to be updated. The triggers linked to the file via association "Has TR" are also updated.
Field sequence |
Y | The field list is to be rearranged to match the sequence of the fields in the DB2 table or view.
Add fields |
Y | Fields in the DB2 table or view missing in the field list are to be inserted in the field list. Distinct types not already documented in standard file SAG-DISTINCT-TYPE will be added as fields. The connection between the standard field and the table field will be established.
Purge fields |
Y | Fields that are missing in the DB2 table or view are to be removed from the field list.
Field attributes |
Y | Attributes of the fields linked to the Predict file object are to be changed to match the DB2 table or view. If a field has a connection to a standard field of SAG-DISTINCT-TYPE and the type definition differs from the DB2 catalog, the field attributes will be updated and the field will be marked non-standard. For files of type E, the attributes that are to be updated include the subselect specification of the SQL create statement for each field. Comments of fields are not updated.
Save set |
Y | Program types and names reported by the function are saved in a set. See also Saving the Result of Comparison Funtions in Sets.

## Comparing DB2 Tables and Views in Batch Mode

Command: `COMPARE TABLE`

Enter parameters on the next line in positional or keyword form.

Field | Keyword | Position
--- | --- | ---
File ID | FILE-ID | 1
Files of type | TYPE | 2
Contained in DA | DB | 3
Check options
File attributes | CHECK-FILE | 4
Fields | CHECK-FIELD | 5
List options
Files | LIST-FILE | 6
Fields | LIST-FIELD | 7
Members using differences | LIST-PROGRAM | 8
Save set | SAVE-SET | 9
Update options
File attributes | UPD-FILE | 10
Field sequences | UPD-SEQUENCE | 11
Add fields | ADD-FIELD | 12
Purge fields | PURGE-FIELD | 13
Fields attributes | UPD-FIELD | 14
SQL Server | SQL-SERVER | 15

If you explicitly set SQL-SERVER to blank in order to use the default server, another keyword must be specified after the SQL-SERVER keyword. If it is not possible to specify another keyword, the SQL-SERVER keyword must be followed by "D1=*" as shown below:

    SQL-SERVER= ,D1=*

### Example

To compare all files of type D or E with prefix "TEST" and display all fields with a different definition, code the command:

    COMPARE TABLE
    FILE-ID=TEST*,LIST-FIELD=D

or

    COMPARE TABLE
    TEST*,,,,,D

The example above uses the Natural parameter `ID=,` and `IA==`.

### On this page

- Prerequisites and Restrictions for DB2 Tables/Views
- Calling the Function: Compare DD Objects with DB2 Files
- Parameters for DB2 Tables/Views
- Comparing DB2 Tables and Views in Batch Mode