DB2 8 - Sample Program Explaining the Simple COBOL+DB2 Program

  1. IDENTIFICATION DIVISION.
  2. PROGRAM-ID. PGM1.
  3. ENVIRONMENT DIVISION.
  4. DATA DIVISION.
  5. WORKING-STORAGE SECTION.

            EXEC SQL
                        INCLUDE PGM1
            END-EXEC.

            EXEC SQL
                        INCLUDE SQLCA
            END-EXEC.

PROCEDURE  DIVISION.
           
            EXEC SQL
                        SELECT EMP_ID,EMP_NAME,EMP_SAL INTO :EMP
                        WHERE EMP_ID = ‘101234’
            End-EXEC.

            DISPLAY :EMP.

            STOP RUN.

Note:
  1.  All Host Variables which are coded with SQL Statements must be prefixed with (:)
  2.  No of colns, No of Host variables must be same with data type length.



Previous
Next Post »