Unload DB2 Tables
Unload DB2 Tables
IKJEFT01 is used to unload the DB2 table from the database and creates a flat file with the data. It uses the DSNTIAUL program to unload data from DB2 tables into sequential data sets. The table data are not affected by the unload operation. DSNTIAUL uses SQL to access DB2.
Syntax -
----+----1----+----2----+----3----+----4----+----5----+
...
//UNLOAD EXEC PGM=IKJEFT01,DYNAMNBR=50
//STEPLIB DD DSN=XXXXXX.SDSNEXIT,DISP=SHR
// DD DSN=XXXXXX.SDSNLOAD,DISP=SHR
//**************DB2 query to unload the data
//SYSIN DD *
db2_query WITH UR;
/*
//SYSTSIN DD *
DSN SYSTEM(DB2T) >> DB2 System
RUN PROGRAM(DSNTIAUL) - >> unloading program
PLAN(DSNTIAUL) - >> Plan authorized for DB2T
LIB('XXXXXX.RUNLIB.LOAD') - >> Program existed library
PARMS('SQL') >> Program Parm
END
//****************Unloading file
//SYSREC00 DD DSN=ps-file-to-unload-table-data,...
//****************Unloading table structure
//SYSPUNCH DD DSN=ps-file-to-store-table-structure,...
//*
...
Practical Example -
Scenario - JCL to unload the db2 table (EMPLOYEE) using IKJEFT01 utility.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//UNLOAD EXEC PGM=IKJEFT01,DYNAMNBR=50
//STEPLIB DD DSN=DSNA10.DBAG.SDSNEXIT,DISP=SHR
// DD DSN=DSNA10.SDSNLOAD,DISP=SHR
//SYSIN DD *
SELECT * FROM EMPLOYEE WITH UR;
/*
//SYSTSIN DD *
DSN SYSTEM(DBAG)
RUN PROGRAM(DSNTIAUL) -
PLAN(DSNTIB10) -
LIB('DSNA10.DBAG.RUNLIB.LOAD') -
PARMS('SQL')
END
/*
//SYSREC00 DD DSN=MATEPK.EMPL.UNLOAD,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//SYSPUNCH DD DSN=MATEPK.EMPL.SYSPUNCH,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
...
Note!
Change the STEPLIB libraries, SYSIN query, SYSTEM, PLAN, LIB, SYSREC00 and SYSPUNCH according to your system setup, and do not change the PROGRAM name.
Once the details are updated, the above JCL can directly submit to run the program.