DB2 Program Preperation
DB2 Program Preperation
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
DB2 Column
Bytes
Bytes
SMALLINT
INTEGER
DECIMAL (p, q)
Int (P/2)
PIC S9(p-q)V9(q)
Integer
((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
char
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.
float
01 identifier COMP-2.
date
time
result set
locator
0C4,
0C5,
0C6
0C7
Data exception program check
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
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.