Again a simple solution for a common problem: how to run a Db2 query from a batch script. Here we use the utility DSNTEP2 that is provided for this purpose with the Db2 installation.
In the STEPLIB, specify your names for Db2 runtime libraries.
In the SYSTEM (xxxx) clause specify your Db2 subsystem.
The SQL in the SYSIN label can be taken from in-stream, or from a dataset as below.
//GO EXEC PGM=IKJEFT01,DYNAMNBR=20 //STEPLIB DD DSN=SYS2.SDSNEXIT,DISP=SHR // DD DSN=SYS2.SDSNLOAD,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM (xxxx) RUN PROG (DSNTEP2) //SYSPRINT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //*SYSIN DD DISP=SHR,DSN=YOURDSN.DB2.SQL(YOURSQL) OR //SYSIN DD * SELECT * FROM YOURTABLE /*
//Dean