Sample REPAIR control statements
Use the sample control statements as models for developing your own REPAIR control statements.
Example: Replacing damaged data and verifying replacement
The following control statement specifies that the REPAIR utility is to perform the following actions:
- Repair the specified page of table space DSN8D81A.DSN8S81D, as indicated by the LOCATE clause.
- Verify that, at the specified offset (50), the damaged data (0A00) is found, as indicated by the VERIFY clause.
- Replace the damaged data with the data that you want (0D11), as indicated by the REPLACE clause.
- Initiate a dump beginning at offset 50, for 4 bytes, as indicated by the DUMP clause. You can use the generated dump to verify the replacement.
//STEP1 EXEC DSNUPROC,UID='IUIQU1UH',UTPROC='',SYSTEM='DSN'
//SYSIN DD *
REPAIR OBJECT
LOCATE TABLESPACE DSN8D12A.DSN8S12D PAGE X'02'
VERIFY OFFSET 50 DATA X'0A00'
REPLACE OFFSET 50 DATA X'0D11'
DUMP OFFSET 50 LENGTH 4
Example: Removing a nonindexed row that is found by REORG
When reorganizing table space DSNDB04.TS1, assume that you received the following message:
DSNU3401 DSNURBXA - ERROR LOADING INDEX, DUPLICATE KEY
INDEX = EMPINDEX
TABLE = EMP
RID OF INDEXED ROW = X'0000000201'
RID OF NONINDEXED ROW = X'0000000503'
To resolve this error condition, submit the following control statement, which specifies that REPAIR is to delete the nonindexed row and log the change. (The LOG keyword is not required; the change is logged by default.) The RID option identifies the row that REPAIR is to delete.
REPAIR
LOCATE TABLESPACE DSNDB04.TS1 RID (X'0000000503')
DELETE
Example: Reporting whether catalog and directory DBDs differ
The following control statement specifies that REPAIR is to compare the DBD for DSN8D2AP in the catalog with the DBD for DSN8D2AP in the directory.
REPAIR DBD TEST DATABASE DSN8D2AP
If the condition code is 0, the DBDs are consistent. If the condition code is not 0, the DBDs might be inconsistent. In this case, run REPAIR DBD with the DIAGNOSE option, as shown in example 4, to find out more detailed information about any inconsistencies.
Example: Reporting differences between catalog and directory DBDs
The following control statement specifies that the REPAIR utility is to report information about the inconsistencies between the catalog and directory DBDs for DSN8D2AP. Run this job after you run a REPAIR job with the TEST option (as shown in example 3), and the condition code is not 0. In this example, SYSREC is the output data set, as indicated by the OUTDDN option.
REPAIR DBD DIAGNOSE DATABASE DSN8D2AP OUTDDN SYSREC
Example: Resetting restrictive states
The following REPAIR statement specifies that the utility is to reset the following restrictive states for the indicated objects:
- For all indexes on table spaces DBNI1601.TSNI1601 and DBNI1601.TSNI1602, reset RBDP, PSRBDP, or RBDP* status.
- For partition 1 of table space DBNI1601.TSNI1601 and partition 4 of table space DBNI1601.TSNI1602, reset ACHKP status.
- For partitions 1 and 4 of table space DBNI1601.TSNI1601, reset CHKP status.
//STEP3 EXEC DSNUPROC,UID='JUNIU116.RECV1',
// UTPROC='',SYSTEM='SSTR'
//SYSIN DD *
REPAIR OBJECT
SET INDEX (ALL) TABLESPACE DBNI1601.TSNI1601 NORBDPEND
SET INDEX (ALL) TABLESPACE DBNI1601.TSNI1602 NORBDPEND
SET TABLESPACE DBNI1601.TSNI1601 PART 1 NOAUXCHKP
SET TABLESPACE DBNI1601.TSNI1602 PART 4 NOAUXCHKP
SET TABLESPACE DBNI1601.TSNI1602 PART 1 NOCHECKPEND
SET TABLESPACE DBNI1601.TSNI1602 PART 4 NOCHECKPEND
/*
Example: Repairing a table space with clones
The control statement specifies that REPAIR is to reset the auxiliary CHECK-pending (ACHKP) status of the specified table space and process only the specified objects that are table spaces that contain clone tables, indexes on clone tables, or index spaces that contain indexes on clone tables.
REPAIR
SET TABLESPACE DBKQDB01.TPKQDB01
NOAUXCHKP CLONE
Example: Checking for incorrect information in the catalog
Assume that you ran the DSN1COPY utility and want to make sure that you did not introduce any data integrity errors. Db2 automatically detects any data and catalog inconsistencies the first time that the data set is physically open after being populated by DSN1COPY. However, if you want to proactively check for these inconsistencies, you can use REPAIR. In this case, suppose that one of the affected table spaces is DBNAMET01.TSNAMET01. Issue the following REPAIR statement:
REPAIR CATALOG TABLESPACE DBNAMET01.TSNAMET01 TEST
This utility control statement specifies that REPAIR is to check for any inconsistencies between the data and catalog. If any inconsistencies are found, Db2 returns messages for them but does not correct them.
REPAIR CATALOG TABLESPACE DBNAMET01.TSNAMET01
For more information about which inconsistencies are automatically corrected and which are reported through messages, see the description of CATALOG in Syntax and options of the REPAIR control statement

Example: Writing a log record
The following utility statement specifies that REPAIR is to write an “add or alter column” diagnostic log record with the value that is passed in the TEXT option:
REPAIR WRITELOG TABLESPACE DB1.TS1 TYPE(X'4400') SUBTYPE(X'0083')
TEXT(X'00011E000200120000000000000000000000')
The following highlighted parts of the TEXT value have the following meanings:
Value | Meaning |
---|---|
TEXT(X'00011E000200120000000000000000000000') | 011E is the DBID |
TEXT(X'00011E000200120000000000000000000000') | 0002 is the PSID |
TEXT(X'00011E000200120000000000000000000000') | 0012 is the length of the log record |
You can determine the DBID and PSID values by querying the SYSIBM.SYSTABLESPACE catalog table. For example:
SELECT SUBSTR(DBNAME,1,8),SUBSTR(NAME,1,10),
HEX(DBID),
HEX(PSID)
FROM SYSIBM.SYSTABLESPACE
WHERE
DBNAME = 'DB1';
The output from the REPAIR utility shows the LRSN of the log record:
DSNU3335I -DB2A 165 12:39:11.45 DSNUCBWL - REPAIR WRITELOG SUCCESSFUL LRSN/RBA: 00D645E15BA022855200
