[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 and SQL   > The Skeleton program for Embedded SQL

Description of the example tables STAFF, ORG, EMP and DEPT

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. 'DB2SKEL'.
000300* SKELETON PROGRAM FOR DB2 EMBEDDED SQL
000400 ENVIRONMENT DIVISION.
000500 INPUT-OUTPUT SECTION.
000600 FILE-CONTROL.
000700 DATA DIVISION.
000800 FILE SECTION.
000900 WORKING-STORAGE SECTION.
001000*  REGULAR WORKING STORAGE THINGS GO HERE AS ALWAYS
001100*  DB2 THINGS COME NEXT: SQLCA AND DECLARATIONS
001200     EXEC SQL
001300            INCLUDE SQLCA
001400     END-EXEC.
001500
001600*    INCLUDE ORG TELLS THE PRECOMPILER
001700*    TO GET THE DECLARATION (DCLGEN) THAT IS IN THIS LIBRARY
001800*    IN PRODUCTION ENVIRONMENT IT IS NOT IN THIS LIBRARY
001900*    SEE PRECOMPILER SYSLIB JCL STATEMENT
002000     EXEC SQL
002100            INCLUDE ORG
002200     END-EXEC.
002300
002400 01  DISPLAY-SQLCODE PIC Z(8)9-.
002500
002600 PROCEDURE DIVISION.
002700     DISPLAY 'STARTING  PROGRAM'.
002800
002900*    SAMPLE SQL STATEMENT IS NEXT
003000     EXEC SQL
003100         SELECT DEPTNAME   INTO :DEPTNAME
003200          FROM ORG
003300          WHERE DEPTNUMB = 10
003400     END-EXEC
003500
003600     EVALUATE SQLCODE
003700       WHEN 0
003800         DISPLAY 'SUCCESSFULLY RETRIEVED FROM ORG ' DEPTNAME
003900       WHEN +100
004000         DISPLAY 'CANNOT FIND ROW '
004100       WHEN OTHER
004200         GO TO ERROR-EXIT
004300      END-EVALUATE
004400
004500     DISPLAY 'FINISHED NOW'.
004600     GOBACK.
004700
004800 ERROR-EXIT.
004900     MOVE SQLCODE TO DISPLAY-SQLCODE.
005000     DISPLAY 'SQLCODE FOLLOWS' DISPLAY-SQLCODE
005100     GOBACK.
005200****
005300**UPDATES, MAINFRAME INFO AT:
005400**HTTP://theamericanprogrammer.com/db2-sql/index.html



Top of Page




















































































List of books on DB2 and other mainframe topics

[Books Computer]

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