Sample SQL precompiler output

The precompiler output can provide information about your program source.

To generate the listing:

The format of the precompiler output is:

Figure 1. Sample COBOL precompiler output format
5722ST1 V5R4M0 060210         Create SQL COBOL Program       CBLTEST1           08/06/02 11:14:21   Page   1
Source type...............COBOL
Program name..............CORPDATA/CBLTEST1
Source file...............CORPDATA/SRC
Member....................CBLTEST1
To source file............QTEMP/QSQLTEMP
(1)Options...................*SRC      *XREF     *SQL
Target release............V5R4M0
INCLUDE file..............*SRCFILE
Commit....................*CHG
Allow copy of data........*YES
Close SQL cursor..........*ENDPGM
Allow blocking............*READ
Delay PREPARE.............*NO
Generation level..........10
Printer file..............*LIBL/QSYSPRT
Date format...............*JOB
Date separator............*JOB
Time format...............*HMS
Time separator ...........*JOB
Replace...................*YES
Relational database.......*LOCAL
User .....................*CURRENT
RDB connect method........*DUW
Default Collection........*NONE
Dynamic default                
   collection..............*NO      
Package name..............*PGMLIB/*PGM
Path......................*NAMING
SQL rules.................*DB2       
User profile..............*NAMING
Dynamic User Profile......*USER
Sort Sequence.............*JOB
Language ID...............*JOB
IBM SQL flagging..........*NOFLAG
ANS flagging..............*NONE
Text......................*SRCMBRTXT
Source file CCSID.........65535
Job CCSID.................65535
Decimal result options:        
  Maximum precision.......31  
  Maximum scale...........31  
  Minimum divide scale....0   
Compiler options..........*NONE   
(2) Source member changed on 06/06/00  10:16:44
1
A list of the options you specified when the SQL precompiler was called.
2
The date the source member was last changed.
5722ST1 V5R4M0 060210       Create SQL COBOL Program  CBLTEST1                   08/06/02 11:14:21   Page   2
(1)Record  *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8   (2)SEQNBR  (3)Last Change
 
    1          IDENTIFICATION DIVISION.                                                       100
    2          PROGRAM-ID.  CBLTEST1.                                                         200
    3          ENVIRONMENT DIVISION.                                                          300
    4          CONFIGURATION SECTION.                                                         400
    5          SOURCE-COMPUTER. IBM-AS400.                                                    500
    6          OBJECT-COMPUTER. IBM-AS400.                                                    600
    7          INPUT-OUTPUT SECTION.                                                          700
    8          FILE-CONTROL.                                                                  800
    9              SELECT OUTFILE, ASSIGN TO PRINTER-QPRINT,                                  900
   10                 FILE STATUS IS FSTAT.                                                  1000
   11          DATA DIVISION.                                                                1100
   12          FILE SECTION.                                                                 1200
   13          FD  OUTFILE                                                                   1300
   14              DATA RECORD IS REC-1,                                                     1400
   15              LABEL RECORDS ARE OMITTED.                                                1500
   16          01  REC-1.                                                                    1600
   17              05  CC                     PIC X.                                         1700
   18              05  DEPT-NO                PIC X(3).                                      1800
   19              05  FILLER                 PIC X(5).                                      1900
   20              05  AVERAGE-EDUCATION-LEVEL PIC ZZZ.                                      2000
   21              05  FILLER                  PIC X(5).                                     2100
   22              05  AVERAGE-SALARY          PIC ZZZZ9.99.                                 2200
   23          01  ERROR-RECORD.                                                             2300
   24              05  CC                      PIC X.                                        2400
   25              05  ERROR-CODE              PIC S9(5).                                    2500
   26              05  ERROR-MESSAGE           PIC X(70).                                    2600
   27          WORKING-STORAGE SECTION.                                                      2700
   28              EXEC SQL                                                                  2800
   29                INCLUDE SQLCA                                                           2900
   30              END-EXEC.                                                                 3000
   31          77  FSTAT                       PIC XX.                                       3100
   32          01  AVG-RECORD.                                                               3200
   33              05  WORKDEPT                PIC X(3).                                     3300
   34              05  AVG-EDUC                PIC S9(4) USAGE COMP-4.                       3400
   35              05  AVG-SALARY              PIC S9(6)V99 COMP-3.                          3500
   36          PROCEDURE DIVISION.                                                           3600
   37         ***************************************************************                3700
   38         *  This program will get the average education level and the  *                3800
   39         *  average salary by department.                              *                3900
   40         ***************************************************************                4000
   41          A000-MAIN-PROCEDURE.                                                          4100
   42              OPEN OUTPUT OUTFILE.                                                      4200
   43         ***************************************************************                4300
   44         * Set-up WHENEVER statement to handle SQL errors.             *                4400
   45         ***************************************************************                4500
   46              EXEC SQL                                                                  4600
   47                WHENEVER SQLERROR GO TO B000-SQL-ERROR                                  4700
   48              END-EXEC.                                                                 4800
1
Record number assigned by the precompiler when it reads the source record. Record numbers are used to identify the source record in error messages and SQL run-time processing.
2
Sequence number taken from the source record. The sequence number is the number seen when you use the source entry utility (SEU) to edit the source member.
3
Date when the source record was last changed. If Last Change is blank, it indicates that the record has not been changed since it was created.
5722ST1 V5R4M0 060210      Create SQL COBOL Program          CBLTEST1            08/06/02 11:14:21   Page   3
Record  *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8   SEQNBR  Last change
   49         ***************************************************************                4900
   50         * Declare cursor                                              *                5000
   51         ***************************************************************                5100
   52              EXEC SQL                                                                  5200
   53                DECLARE CURS CURSOR FOR                                                 5300
   54                  SELECT WORKDEPT, AVG(EDLEVEL), AVG(SALARY)                            5400
   55                    FROM CORPDATA.EMPLOYEE                                              5500
   56                    GROUP BY WORKDEPT                                                   5600
   57              END-EXEC.                                                                 5700
   58         ***************************************************************                5800
   59         *  Open cursor                                                *                5900
   60         ***************************************************************                6000
   61              EXEC SQL                                                                  6100
   62                OPEN CURS                                                               6200
   63              END-EXEC.                                                                 6300
   64         ***************************************************************                6400
   65         *  Fetch all result rows                                      *                6500
   66         ***************************************************************                6600
   67              PERFORM A010-FETCH-PROCEDURE THROUGH A010-FETCH-EXIT                      6700
   68                UNTIL SQLCODE IS = 100.                                                 6800
   69         ***************************************************************                6900
   70         *  Close cursor                                               *                7000
   71         ***************************************************************                7100
   72              EXEC SQL                                                                  7200
   73                CLOSE CURS                                                              7300
   74              END-EXEC.                                                                 7400
   75              CLOSE OUTFILE.                                                            7500
   76              STOP RUN.                                                                 7600
   77         ***************************************************************                7700
   78         *  Fetch a row and move the information to the output record. *                7800
   79         ***************************************************************                7900
   80          A010-FETCH-PROCEDURE.                                                         8000
   81              MOVE SPACES TO REC-1.                                                     8100
   82              EXEC SQL                                                                  8200
   83                FETCH CURS INTO :AVG-RECORD                                             8300
   84              END-EXEC.                                                                 8400
   85              IF SQLCODE IS = 0                                                         8500
   86                MOVE WORKDEPT TO DEPT-NO                                                8600
   87                MOVE AVG-SALARY TO AVERAGE-SALARY                                       8700
   88                MOVE AVG-EDUC TO AVERAGE-EDUCATION-LEVEL                                8800
   89                WRITE REC-1 AFTER ADVANCING 1 LINE.                                     8900
   90          A010-FETCH-EXIT.                                                              9000
   91              EXIT.                                                                     9100
   92         ***************************************************************                9200
   93         *  An SQL error occurred.  Move the error number to the error *                9300
   94         *  record and stop running.                                   *                9400
   95         ***************************************************************                9500
   96          B000-SQL-ERROR.                                                               9600
   97              MOVE SPACES TO ERROR-RECORD.                                              9700
   98              MOVE SQLCODE TO ERROR-CODE.                                               9800
   99              MOVE "AN SQL ERROR HAS OCCURRED" TO ERROR-MESSAGE.                        9900
  100              WRITE ERROR-RECORD AFTER ADVANCING 1 LINE.                               10000
  101              CLOSE OUTFILE.                                                           10100
  102              STOP RUN.                                                                10200
* * * * *  E N D  O F  S O U R C E  * * * * *
5722ST1 V5R4M0 060210          Create SQL COBOL Program      CBLTEST1              08/06/02 11:14:21   Page     4
CROSS REFERENCE
1                             2       3
Data Names                    Define    Reference
AVERAGE-EDUCATION-LEVEL          20       IN REC-1
AVERAGE-SALARY                   22       IN REC-1
AVG-EDUC                         34       SMALL INTEGER PRECISION(4,0) IN AVG-RECORD
AVG-RECORD                       32       STRUCTURE
                                          83
AVG-SALARY                       35       DECIMAL(8,2) IN AVG-RECORD
BIRTHDATE                        55       DATE(10) COLUMN IN CORPDATA.EMPLOYEE
BONUS                            55       DECIMAL(9,2) COLUMN IN CORPDATA.EMPLOYEE
B000-SQL-ERROR                   ****     LABEL
                                          47
CC                               17       CHARACTER(1) IN REC-1
CC                               24       CHARACTER(1) IN ERROR-RECORD
COMM                             55       DECIMAL(9,2) COLUMN IN CORPDATA.EMPLOYEE
CORPDATA                         ****   (4) COLLECTION
                                        (5) 55
CURS                             53       CURSOR
                                          62 73 83
DEPT-NO                          18       CHARACTER(3) IN REC-1
EDLEVEL                          ****     COLUMN
                                          54
                                           (6)
EDLEVEL                          55       SMALL INTEGER PRECISION(4,0) COLUMN (NOT NULL) IN CORPDATA.EMPLOYEE
EMPLOYEE                         ****     TABLE IN CORPDATA                                      (7)
                                          55
EMPNO                            55       CHARACTER(6) COLUMN (NOT NULL) IN CORPDATA.EMPLOYEE
ERROR-CODE                       25       NUMERIC(5,0) IN ERROR-RECORD
ERROR-MESSAGE                    26       CHARACTER(70) IN ERROR-RECORD
ERROR-RECORD                     23       STRUCTURE
FIRSTNME                         55       VARCHAR(12) COLUMN (NOT NULL) IN CORPDATA.EMPLOYEE
FSTAT                            31       CHARACTER(2)
HIREDATE                         55       DATE(10) COLUMN IN CORPDATA.EMPLOYEE
JOB                              55       CHARACTER(8) COLUMN IN CORPDATA.EMPLOYEE
LASTNAME                         55       VARCHAR(15) COLUMN (NOT NULL) IN CORPDATA.EMPLOYEE
MIDINIT                          55       CHARACTER(1) COLUMN (NOT NULL) IN CORPDATA.EMPLOYEE
PHONENO                          55       CHARACTER(4) COLUMN IN CORPDATA.EMPLOYEE
REC-1                            16
SALARY                           ****     COLUMN
                                          54
SALARY                           55       DECIMAL(9,2) COLUMN IN CORPDATA.EMPLOYEE
SEX                              55       CHARACTER(1) COLUMN IN CORPDATA.EMPLOYEE
WORKDEPT                         33       CHARACTER(3) IN AVG-RECORD
WORKDEPT                         ****     COLUMN
                                          54 56
WORKDEPT                         55       CHARACTER(3) COLUMN IN CORPDATA.EMPLOYEE
No errors found in source
102 Source records processed
* * * * *  E N D  O F  L I S T I N G  * * * * *
1
Data names are the symbolic names used in source statements.
2
The define column specifies the line number at which the name is defined. The line number is generated by the SQL precompiler. **** means that the object was not defined or the precompiler did not recognize the declarations.
3
The reference column contains two types of information:
  • What the symbolic name is defined as 4
  • The line numbers where the symbolic name occurs 5

If the symbolic name refers to a valid host variable, the data-type 6 or data-structure 7 is also noted.