Validating WSLs

Validating a WSL enables you to generate a report about the syntax and the impact to other objects.

About this task

Before you run a WSL, you might want to have the syntax of the SQL statements checked and assess the impact that running the WSL would have on objects.

When you validate a WSL, Db2 Admin Tool checks the syntax of each SQL statement in isolation from any other SQL statements in the WSL; it ignores any SQL statements that precede the statement currently being checked. Thus, Db2 Admin Tool can generally report all syntactic errors but might miss semantic errors that can result from not being able to see previous statements. For example, if the name of a data type is required in a certain position in the syntax, Db2 Admin Tool does not verify that the name of the data type is either a built-in data type or a user-defined data type that has been previously defined.
Note: For native SQL procedures, even if validation is successful, the object's existence in the body of the native SQL procedure cannot be known at procedure run time (or during procedure call).

The impact analysis portion of the validate report lists the impact to the objects by these categories:

Implicitly dropped objects
Existing objects that are implicitly dropped but not re-created by the WSL.
Explicitly dropped objects
Existing objects that are explicitly dropped but not re-created by the WSL.
Recreated objects
Existing objects that are implicitly or explicitly dropped and re-created by the WSL.
Altered objects
Existing objects that are altered by the WSL.
Created objects
Objects that did not exist and are created by the WSL.
Temporary objects
Objects that did not exist and are created and then dropped by the WSL.

Each affected object is included in only one of these categories.

After the initial validation, you can add custom validation rules for objects from Object Compare, CM Analyze, and CM Batch functions. To perform a custom validation, you must write the REXX exec that is used to perform the validation. You can specify the name of your REXX exec on the Options for Change Functions panel (ADB2PCO). The name of your REXX exec is then stored in your profile shared pool. During the validation process, the REXX exec name will be added to the JCL as the value for the STMTEXIT parameter. The REXX exit cannot connect to Db2, because the connection between Db2 Admin Tool and Db2 is already active.

The REXX exec will be called with the following parameters:
  • Statement type
  • Object type
  • Object qualifier
  • Object name
You can decide how to perform the validation based on these parameters.

The custom validation function will continue processing until all validations are complete and all errors are reported. Validation errors are written to a separate DD file called VALOUT and use the data set name prefix that you specify. An example of a data set name is SYSADM.E344.VALOUT. Each error message from the REXX exec consists of a return code followed by a colon and the message string, as shown in the example below.

'08:Changes in database not allowed'

The return string from the REXX exec is saved to the VALOUT DD in the format shown in the example below.

SUPPLEMENTAL VALIDATE WORK STATEMENT LIST REPORT                  
================================================                                           
Prepared on DSN7 (DB2 Release 720) by NBRON at 2006-07-08 10:48
for NBRON.WLIST.VALIDATE(SAMPLE)

ADB3036E RC=08 An error occurred while processing the ALTER DB statement:
CHANGES IN DATABASE NOT ALLOWED

If an object does not require validation, or if there are no errors, the REXX exec returns the code '00'.

Procedure

To validate a WSL:

  1. On the DB2 Administration Menu (ADB2) panel, specify option W, and press Enter.
  2. On the Manage Work Statement Lists (ADB2W) panel, in the Work stmt list dsn field, specify the data set name of the ISPF library that contains the WSLs.
  3. Specify option 1, and press Enter.
  4. On the Work Statement List Library (ADB2W1) panel, specify the V line command against a WSL, and press Enter:
    Figure 1. Work Statement List Library panel (ADB2W1)
     ADB2W1 in ----------------- Work Statement List Library ------ Row 1 to 6 of 6
    Command ===>                                                  Scroll ===> CSR 
                                                                                  
    Commands: OPTIONS                                                             
    Line commands:                                                                
     S - Show  R - Run (batch)   D - Delete  C - Copy  A - Append  Q - Clone      
     I - Interpret  V - Validate  E - Edit  B - Checkpoint 
     ? - Show all line commands                        
                                                                                  
    Work Statement List: WSL.LIST                                                 
                                                                                  
    Sel Name     Created    Changed          ID       Restart                     
        *        *          *                *        *                           
    --- -------- ---------- ---------------- -------- --------                    
        C0000023 2013/04/05 2013/04/05 09:15 VNDDHG                               
        DG29608  2013/04/05 2013/04/05 14:17 VNDDHG                               
        D1026676 2013/03/27 2013/03/27 10:03 VNDDHG                               
        D25359   2013/03/27 2013/03/27 10:47 VNDDHG                               
        REO26676 2013/03/18 2013/03/18 14:04 VNDDHG                               
        S28654   2013/02/28 2013/03/28 12:38 VNDDHG   Y
    The JCL to generate the batch job to produce the Validate Work Statement List report is displayed.
  5. Submit the JCL.
    The Validate Work Statement List report is generated and displayed, as shown in the following figure.
    Figure 2. Validate Work Statement List report (1 of 2)
                                     
     -------------------------------------------------------------------------------
     SDSF OUTPUT DISPLAY NBRONV   J0086325  DSID   105 LINE 1       COLUMNS 02- 81  
     COMMAND INPUT ===>                                            SCROLL ===> PAGE 
    --------------------------------------------------------------------------------
    ADB2WVL - Validate Work Statement List                                          
    --------------------------------------------------------------------------------
                                                                                    
              DB2 Administration Tool                                               
              5697-L90 (C) Copyright IBM Corporation 2001, 2005.                    
              All rights reserved.  Licensed materials - property of IBM.           
              US Government Users Restricted Rights - Use, duplication or disclosure
              restricted by GSA ADP schedule contract with IBM Corp. 
    
    --------------------------------------------------------------------------------
    REFERENCE FOR CATALOG OBJECT STATUS                                             
    --------------------------------------------------------------------------------
    IMPLICITLY DROPPED OBJECTS - Existing catalog objects that are implicitly       
                                 dropped and not recreated by the WSL.              
    TEMPORARY OBJECTS          - Objects that are created and dropped during        
                                 execution of the WSL.  Temporary objects do not    
                                 exist in the catalog before or after WSL execution.
    CREATED OBJECTS            - Objects that are created by the WSL that did not   
                                 exist in the catalog.                              
    EXPLICITLY DROPPED OBJECTS - Existing catalog objects that are explicitly       
                                 dropped and not recreated by the WSL.              
    ALTERED OBJECTS            - Existing catalog objects that are modified by      
                                 ALTER statements in the WSL.                       
    RECREATED OBJECTS          - Existing catalog objects that are implicitly or    
                                 explicilty dropped and later recreated by the WSL. 
    --------------------------------------------------------------------------------
                                                                                    
                                                                                    
    VALIDATE WORK STATEMENT LIST REPORT                                             
    ===================================                                             
                                                                                    
    Prepared on DSN7 (DB2 Release 720) by NBRON at 2006-07-08 10:48                 
    for NBRON.WLIST.VALIDATE(SAMPLE)                                                
                                                                                    
    SQL error in PREPARE for statement:                                             
     CREATE SEQUENCE ORDER_SEQ             START WITH 1             INCREMEN        
     DSNT408I SQLCODE = -104, ERROR:  ILLEGAL SYMBOL "START". SOME SYMBOLS THAT     
              MIGHT BE LEGAL ARE: FOR                                               
     DSNT418I SQLSTATE   = 42601 SQLSTATE RETURN CODE                               
     DSNT415I SQLERRP    = DSNHPARS SQL PROCEDURE DETECTING ERROR                   
     DSNT416I SQLERRD    = 0  0  0  -1  40  0 SQL DIAGNOSTIC INFORMATION            
     DSNT416I SQLERRD    = X'00000000'  X'00000000'  X'00000000'  X'FFFFFFFF'       
              X'00000028'  X'00000000' SQL DIAGNOSTIC INFORMATION                   
                                                                                    
    Error processing Database  ABCDE in a ALTER statement:Object does not exist     
    Error processing Table DSN8720.ABCDTB in a ALTER statement:Object does not exist
    Error processing Table DSN8720.DEPT in a ALTER statement:Object does not exist  
    Error processing Table DSN8720.ABCDTB in a ALTER statement:Object does not exist
    Error processing Index DSN8720.ABCDIX in a ALTER statement:Object does not exist
    Error processing Index DSN8720.XDEPT1 in a ALTER statement:Object does not exist
    Error processing Sequence NBRON.org_seq in a ALTER statement:Object does not exist
    Error processing Sequence VNDSHL2.SEQ14 in a CREATE statement:Object already exists
    Error processing Sequence VNDSHL2.SEQ13 in a DROP statement:Object does not exist
    .                                                                               
    .                                                                               
    . 
    Figure 3. Validate Work Statement List report (2 of 2)
    .                                                                               
    .                                                                               
    .                                                                                
    IMPLICITLY DROPPED OBJECTS                                                      
    --------------------------                                                      
      Referential constraint AHXTOOLS.PROJACT                                       
      Referential constraint AHXTOOLS.PROJ                                          
      Referential constraint AHXTOOLS.PROJ                                          
      Referential constraint AHXTOOLS.DEPT                                          
      Referential constraint AHXTOOLS.PROJ                                          
      Referential constraint AHXTOOLS.PROJACT                                       
      Referential constraint AHXTOOLS.DEPT                                          
                                                                                  
    ALTERED OBJECTS                                                                 
    ---------------                                                                 
      Function NBRON.SPECIFICFFFF1                                                  
                                                                                    
                                                                                    
    TEMPORARY OBJECTS                                                               
    -----------------                                                               
      Sequence NBRON.org_seq                                                        
      Table Space DSN8D72A.DSN8S72D                                                 
      Table DSN8720.DEPT                                                            
      Table DSN8720.ABCDTB                                                          
                                                                                    
                                                                                    
    CREATED OBJECTS                                                                 
    ----------------                                                                
      Table NBRON.TBDSN80                                                           
                                                                                    
                                                                                    
    RECREATED OBJECTS                                                               
    ------------------                                                              
      Table QUADPB02.TBADPB02                                                       
      Table Space DBADPB02.TPADPB01                                                 
      View QUADPB02.VWADPB02                                                        
      View QUADPB02.VWADPB04                                                        
      View QUADPB02.VWADPB05                                                        
      View QUADPB02.VWADPB06                                                        
      View QUADPB02.VWADPB09                                                        
      View QUADPB02.VWADPB12                                                        
      View QUADPB02.VWADPB14                                                        
      View QUADPB02.VWADPB15                                                        
      View QUADPB02.VWADPB16                                                        
      View QUADPB02.VWADPB17                                                        
      View QUADPB02.VWADPB18                                                        
      View QUADPB02.VWADPB19                                                        
      Index QUADPB02.IPADPB01                                                       
      Index QUADPB02.IPADPB02                                                       
      Referential constraint QUADPB02.TBADPB02 QUADPB02.TBADPB01 FKADPB03           
      Referential constraint QUADPB02.TBADPB01 QUADPB02.TBADPB02 FKADPB02           
      Referential constraint QUADPB02.TBADPB04 QUADPB02.TBADPB02 FKADPB04           
      Referential constraint QUADPB02.TBADPB05 QUADPB02.TBADPB02 FKADPB07           
    

What to do next

After the initial validation completes, you can impose additional custom validation rules to Db2 objects.
  • For Object Compare and CM Analyze, use the STMTEXIT parameter. The value for this parameter can be found on the Options for Change Functions panel (ADB2PCO). You can manually update that value by changing it in the JCL, then submitting the JCL.
    //ADBWL    DD DISP=SHR,                                                 
    //         DSN=SYSADM.WSL                                      
    //CAT      DD DSN=&&CATOUT2,                                            
    //         DCB=(LRECL=16800,RECFM=VB,DSORG=PS),                         
    //         SPACE=(TRK,(15,15),RLSE),                                    
    //         UNIT=SYSDA,                                                  
    //         DISP=(NEW,PASS)  
    //ADBUEXEC DD DISP=SHR,DSN=SPF.PRODUCT.ISPTLIB                                            
    //ADBUEXE1 DD DISP=SHR,DSN=SPF.PRODUCT.ISPTLIB
    //VALOUT   DD SYSOUT=*
    //IN       DD *                                                         
      DB2SYS    = DSNB,                                                     
      DB2ALOC   =                                                           
      DB2SERV   = DSNB                                                      
      DB2AUTH   = 'S22957'                                                   
      DB2REL    = 1115                                                      
      ADBTEST   = YES,                                                      
      PLAN      = ADB,                                                  
      ADBASUSR  = ,                                                         
      ADBASUSB  = NO,   
      SRCWSLST  = TEST3,                           
      SRCWSLIB  = SYSADM.WSL,             
      STMTEXIT  = TEST                                   
    /*                                             
    /*                                             
    
  • For CM Batch, use the VALIDATION_STMTEXIT parameter. This parameter does not have a default value.
    //* DB2 ADMIN ISPF BATCH                                                
    //*                                                                     
    //T03REG EXEC GOCCM,SSID=DSNB,PLAN=ADBDEV,GRP=UB2DEV0,USRGRP=S45801     
    //GOCCM.PARMS  DD *                                                     
     ACTION_IMPORT_CHANGE='N'                                               
     ACTION_ANALYZE_CHANGE='Y'                                              
     CHANGE_OWNER='S22957'                                                 
     CHANGE_NAME='IMPORT_DSTCHANGE'                                         
     PDS_FOR_WSL='SYSADM.WSL'                                      
     VALIDATE_STMTEXIT='TEST'                                    
     CHANGE_COMMENT=''                                                      
     ;