COBOL Divisions:
1) IDENTIFICATION DIVISION.
PROGRAM-ID. Entry
[AUTHOR. entry.] [INSTALLATION. entry.]
[DATE-WRITTEN. entry.]
Optional
[DATA-COMPILED. entry.]
[SECURITY. entry.]
[REMARKS. entry.]
2) ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. source-computer-entry.
OBJECT-COMPUTER. object-computer-entry.
[SPECIAL NAMES. special-computer-entry].
INPUT-OUTPUT SECTION.
FILE CONTROL. {file-control-entry}.
[I-O-CONTROL. input-output-control-entry].
3) DATA DIVISION.
FILE SECTION.
LINKAGE SECTION
WORKING-STORAGE SECTION.
4) PROCEDUE DIVISION.
5) WORKING-STORAGE SECTION.
6) EXEC SQL
7) DECLARE C1 CURSOR FOR
8) SELECT DEPTNO, DEPTNAME, MGRNO
9) FROM DEPT
10) WHERE ADMRDEPT = :ADMRDEPT
11) FOR UPDATE OF MGRNO
12) END-EXEC.
EXEC SQL
DECLARE CURSOR SAMPCURS WITH ROWSET POSITIONING FOR
SELECT DEPTNO
FROM
DSN81010.DEPT
END-EXEC.
Object
Source
Modified source
Description
Every program starts as a series of host language
statements, known as the application source. The source is
run through the DB2 pre-compiler to have its SQL
statements removed and placed in a DBRM.
The DB2 pre-compiler creates the modified source module
by stripping the source module of all its SQL statements.
The modified source is passed to the host language
compiler.
Load module
DBRM
Package
Plan
Collection
Version
The linkage editor creates a load module using the output of
the host language compiler. The load module contains the
executable form of the host language statements and is
executable with an application plan.
The DBRM is created by the DB2 pre-compiler from the SQL
statements stripped from the program source code.
A package also is created by the BIND statement. It contains
the access paths for a single DBRM. It must be specified in
the package list of a plan before it can be executed (with
the appropriate load module for the program).
A plan is created by the BIND statement. It consists of a list
of one or more packages. The plan is executable with the
corresponding program load module.
A collection is an identifier used to control the creation of
multiple packages from the same DBRM. (Technically, a
collection is not an object, but it is included in this list for
completeness.)
A version is a token specified to the DB2 pre-compiler that
enables multiple versions of the same collection and
package to exist.
DB2 Column
Bytes
COBOL PIC Clause
Bytes
SMALLINT
PIC S9(04) COMP
INTEGER
PIC S9(09) COMP
DECIMAL (p, q)
Int (P/2)
PIC S9(p-q)V9(q)
Integer
(P should be less than 32)
((P+Q)/2 +1)
DATE
PIC X(10)
TIME
PIC X(08)
TIMESTAMP
10
PIC X(26)
26
yyyy-mm-ddhh.mm.ss.nnnnnn
CHAR(n) (n=1 to 254)
PIC X(n)
VARCHAR(n) (n=0-4046)
01 WS-COLUMN.
N+2
49 WS-COLUMNLENGTH PIC
S9(04) COMP
49 WS-COLUMN
TEXT
Data Type
COBOL Data Declaration
char
01 identifier PIC X(n).
01 identifier PICTURE IS X(n).
varchar
01 identifier
49 identifier PIC S9(ni) COMP.
49 identifier PIC X(nc).
smallint
01 identifier PIC
01 identifier PIC
01 identifier PIC
COMP.
integer
01 identifier PIC
01 identifier PIC
01 identifier PIC
COMP.
decimal
01 identifier PIC
01 identifier PIC
01 identifier PIC
3.
01 identifier PIC
IS COMP-3.
PIC X(n)
Comments
n is a positive integer
representing the length of the
CHAR column value assigned to
the host variable.
ni is a positive integer from 1 to
4, representing the length of the
numeric column value assigned
to the variable containing the
string length.
nc is a positive integer equal to
the length of the largest
VARCHAR column value that can
be assigned to the host variable.
S9(4) COMP.
n is a positive integer from 1 to
4, representing the variable
S9(n) COMP.
length. No decimal points are
S9(n) USAGE IS
allowed. Anything other than 9s
in the Picture clause makes data
item unacceptable as a host
variable. PIC S and COMP are
required. You may use COMP-4
or COMP-5 in place of COMP if
necessary.
S9(9) COMP.
n is a positive integer from 5 to
9. No decimal point is allowed.
S9(n) COMP.
Anything other than 9s in the
S9(n) USAGE IS
Picture clause will make the
data item unacceptable as a
host variable. PIC S and COMP
are required. You may use
COMP-4 or COMP-5 in place of
COMP if necessary.
S9V COMP-3.
n and m are positive
integers; n + m cannot exceed
S9(n) V COMP-3.
15. You must include a V to
S9(n) V9(m) COMP- denote the decimal point.
Anything other than 9s and a V
S9(n) V9(m) USAGE in the Picture clause will make
the data item unacceptable as a
host variable. PIC S and COMP-3.
are required.
float
01 identifier COMP-2.
date
01 identifier USAGE IS COMP-3.
01 identifier PIC X(n).
01 identifier PICTURE IS X(n).
time
01 identifier PIC X(n).
01 identifier PICTURE IS X(n).
result set
locator
0C4,
0C5,
0C6
01 identifier SQL TYPE IS RESULTSET- LOCATOR.
COMP-2. or COMP-3. is required.
n must be an integer
representing the length of the
date string. For example, if the
date string is in the format
MM/DD/YY, n may equal 8. If in
the format MM/DD/YYYY, n
should equal 10. Make sure your
date format is set correctly in
the Options utility. See the
Option utility's online help for
information about modifying the
date/time representation.
n must be an integer
representing the length of the
time string. To include
seconds, n must be at least 8.
For example, a time string in the
format HH:MM requires
that n equal at least 5, while a
time string in the format
HH:MM:SS requires that n equal
at least 8.
A 4-byte value used by DB2 to
uniquely identify a query result
set returned by a stored
procedure.
Addressing program check
Runaway or uninitialized subscript or index
Missing or invalid DD statement
Reading from or writing to an unopened file
Opening or closing the file twice
Dropping off the end of the program
Using a divisor or multiplier that is too large
Using the wrong SORTLIB in a COBOL sort
0C7
Data exception program check
Data item not initialized
DISPLAY data moved to a numeric group item
Improper definition in the LINKAGE SECTION
Invalid or misaligned data in an input file
Improper initialization using MOVE ZERO
Runaway or uninitialized subscript or index
322
The job exceeded the amount of time allowed by the system or by the TIME
parameter of the JOB or EXEC JCL statement. Check to determine if the program
is looping.
337
The disk doesn't have enough space to allocate the file
722
The number of print lines exceeds the system limit for the file. Check to determine
if your program is looping. If not, modify the JCL to increase the number of lines
permitted.
806
A requested program wasn't found in the system libraries specified.
D37
A file requires more disk space than was requested by the DD statement. This can
be caused by underestimating the amount of storage needed for the file, or a
program loop that contains a WRITE statement.
E37
The disk does not contain enough available space to allocate the amount requested
for a file.
00 Successful completion
10 No next logical record exists. You have reached the end of the file.
20 Device or resource busy (Micro Focus).
NEXT: Will FETCH the next row, the same way that the pre-V7 FETCH statement functioned.
PRIOR: Will FETCH the previous row.
FIRST: Will FETCH the first row in the results set.
LAST: Will FETCH the last row in the results set.
CURRENT: Will re-FETCH the current row from the result set.
BEFORE: Positions the cursor before the first row of the results set.
AFTER: Positions the cursor after the last row of the results set.
ABSOLUTE n: Will FETCH the row that is n rows away from the first row in the
results set.
RELATIVE n: Will FETCH the row that is n rows away from the last row fetched.