[USflag] The American Programmer [USflag]


Home
Books on Mainframe Programming
Mainframe Manuals and Tutorials
System Abend codes, Sqlcodes, VSAM/QSAM codes
Everything about the IBM AS/400 Midrange Computer
Everything about CICS
Everything about COBOL
Everything about DB2 and SQL
  DB2/SQL Singleton Select embedded in a COBOL program
  DB2/SQL Add Change Delete program
  DB2/SQL program to read table with cursor
  DB2/SQL load table program
  DB2/SQL program to read a table randomly
  DB2/SQL bare bones skeleton program
  DB2/SQL program to insert a row into a table
  DB2/SQL program to update a row
  DB2/SQL program for handling variable length column
  DB2/SQL program for handling column with null indicator
  Embedded SQL. Short tutorial.
  Examples of DCLGEN. Short tutorial.
  Examples of SQL Joins. Short tutorial.
  Examples of DB2 View. Short tutorial.
  Just Enough SQL/QMF/SPUFI To Be Dangerous
  Sample tables STAFF, ORG, EMP and DEPT
  QMF Procedures Written in REXX
  Using REXX Subroutines with the QMF Calc panel
  Using QMF to Execute Your SQL
  QMF Cheat Sheet. Edit codes. QMF Commands, Text Variables, Usage Codes
  Executing SQL in a batch job
  Using Spufi to Execute Your SQL
  Books on DB2 and SQL
  DB2 and SQL, Structured Query Language manuals
  SQLCODES and Their Causes
Everything about IMS
Everything about Java and JavaScript
Everything about JCL and JES
Everything about REXX
Everything about zOS, VSAM, Tivoli, Assembler
Everything about TSO, ISPF, Spufi
Site Map and Site Search

           Home   > DB2   > SQL Batch

SQL in Batch

You may want to execute some SQL in a batch job. You may want to do a SELECT to display data. You may want to do other SQL commands, such as INSERT, UPDATE or DELETE.

By submitting your job to batch you will free up your terminal and possibly use less CPU time than you would on-line. In addition, if your batch job appears to go into a loop, you can easily cancel it from your terminal.

 

Generic JCL for executing SQL in batch.

//*THIS WILL EXECUTE SQL IN BATCH with the utility.
//*YOU NEED TO KNOW YOUR DB2-SUBSYSTEM NAME
//*FILL IT IN BELOW
//*
//*THIS CAN EXECUTE > 1 QUERY - SEPARATE THEM WITH SEMICOLON
//*
//*
//RUNSQL EXEC PGM=IKJEFT1A
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=T
//SYSTSIN DD *
DSN SYSTEM(db2-subsystem)
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP2)
END
//SYSIN DD *
SELECT * FROM Q.STAFF;
/*

 

You will find a large selection of mainframe books at:Books. You’ll find manuals on TSO, JCL, REXX, COBOL, DB2 at:Manuals.



[Books Computer]

Home Books for Computer Professionals Privacy Terms |
Site Map and Site Search Programming Manuals and Tutorials The REXX Files Top of Page |