Professional Documents
Culture Documents
JES3 allocates datasets for all the steps before the job is scheduled. In JES2,
allocation of datasets required by a step are done only just before the step
executes.
An MVS subsystem that receives jobs into the system,converts them to internal
format, selects them for execution, processes their output, and purges them from
the system. In complexes that have several loosely coupled processing units, the
JES3 program manages processors so that the global processor exercises
centralized control over the local processors and distributes jobs to them via a
common job queue.
An MVS subsystem that receives jobs into the system, converts them to internal
format, selects them for
execution, processes their output, and purges them from the system. In an
installation with more than one processor, each processor's JES2 subsystem
independently controls job input, scheduling, and output processing.
In a mainframe installation that has only one processor, JES3 provides tape setup,
dependent job control, and deadline scheduling for users of the system, while JES2
in the same system would require its users to manage these activities through other
means. In an installation with a multiprocessor configuration, there are noticeable
differences between the two, mainly in how JES2 exercises independent control over
its job processing functions. That is, within the configuration, each JES2 processor
controls its own job input, job scheduling, and job output processing. In cases where
multiple z/OS® systems are clustered (a sysplex), it is possible to configure JES2 to
share spool and checkpoint data sets with other JES2 systems in the same sysplex.
This configuration is called Multi-Access Spool (MAS). In contrast, JES3 exercises
centralized control over its processing functions through a single global JES3
processor. This global processor provides all job selection, scheduling, and device
allocation functions for all of the other JES3 systems. With JES3, installations may
decide whether the global JES3 or z/OS base control program will handle device
allocation. With JES2, only the z/OS base control program handles device allocation.
1
what is the difference between plan and package? why package is not a
executable?
if there r modifications in the sub program its just enough to crete a package 4 that
sub pgm.
lock options and various bind options can b controlled even in the subpgm level
itself.
If you've 5 programs, you create 5 distinct PACKAGEs and then club them together
using a PLAN. So, in your case, you will have to update (re-bind) the PACKAGE that
represents the changed program and your PLAN will automatically take the latest
one.
You can create a different package version for each version of the program. Each package has
the same package name and collection name, but a different version number is associated with
each package. The plan that includes that package includes all versions of that package. Thus,
you can run a program that is associated with any one of the package versions without having to
rebind the application plan, rename the plan, or change any RUN subcommands that use it.
2
To create a package version:
Example: Suppose that you bound a plan with the following statement:
BIND PLAN (PLAN1) PKLIST (COLLECT.*)
The following steps show how to create two versions of a package, one for each of two
programs.
Step number For package version 1 For package version 2
1 Precompile program 1. Specify Precompile program version 2.
VERSION(1). Specify VERSION(2).
2 Bind the DBRM with the collection Bind the DBRM with the collection
name COLLECT and the package name COLLECT and package name
name PACKA. PACKA.
3 Link-edit program 1 into your Link-edit program 2 into your
application. application.
4 Run the application; it uses program 1 Run the application; it uses program 2
and PACKA, VERSION 1. and PACKA, VERSION 2.
When you run the program, DB2 uses the consistency token in matching the call to DB2 to the
correct DBRM. Usually, the consistency token is in an internal DB2 format. You can override
that token if you want.
You also need other identifiers. The consistency token alone uniquely identifies a DBRM that is
bound directly to a plan, but it does not necessarily identify a unique package. When you bind
DBRMs directly to a particular plan, you bind each one only once. But you can bind the same
DBRM to many packages, at different locations and in different collections, and then you can
include all those packages in the package list of the same plan. All those packages will have the
3
same consistency token. You can specify a particular location or a particular collection at run
time.
It's the DD name used by TSO to enter in-stream TSO commands. The reason you
see it in DB2 jobs is that IBM uses TSO as one of the techniques for running DB2
jobs in batch mode.
The SYSTSIN DD statement is used to specify that the data to follow consists of executable
commands and/or subcommands. For example, to indicate to the system that all data following
this statement is to be used as input, until the system encounters an input delimiter, such as the
characters /* or the DLM operand, specify:
//SYSTSIN DD *
If any of the input statements start with the characters //, use the DD DATA statement instead.
4
To indicate to the system that all data following this statement is to be used as input, including
statements that start with the characters //, until an input delimiter (/* or DLM) is found,
specify:
//SYSTSIN DD DATA
To indicate to the system that all the input data can be found in data set PREFIX.INPUT.DATA,
specify:
//SYSTSIN DD DSNAME=PREFIX.INPUT.DATA
SYSTSIN DD Statement
The SYSTSIN and SYSTSPRT DD statements can refer to a sequential data set or a
member of a partitioned data set.
It is recommended that the SYSTSIN DD be defined as a fixed block format data set,
with an LRECL of 80.
If SYSTSIN is a fixed length data set (FB), the last 8 bytes of the record will be
treated as a sequence number and ignored.
If SYSTSIN is a fixed length data set with ASA control characters (FBA), the first byte
of the record will be treated as a carriage control character and ignored.
If SYSTSIN is a variable length data set (VB), the first 8 bytes of the record will be
treated as a sequence number and ignored.
If SYSTSIN is a variable length data set with ASA control characters (VBA), the first 9
bytes of the record will be treated as a sequence number, followed by a carriage
control character and ignored.
You cannot refer to concatenated data sets on the SYSTSIN DD statement. Each
command or subcommand must begin on a separate statement.
What is check pending and copy pending status in DB2, how do you resolve it?
If the table is loaded with ENFORCE NO option then the table space get into check
pending status. That means table space is loaded without enforcing constraints.
CHECK utility needs to be run on table space.
If table is loaded with LOG NO option then it get's into cpoy pending status. The
meaning is image copy is needed on table space.
• CHECK LOB
5
1. Check and correct referential integrity constraints using the CHECK DATA utility.
2. COPY-pending (COPY) restrictive status indicates that the affected object must be
copied
In Copy pending status the table is available only for query processing. The solution
of copy pending status is take an image copy or use repair utility.
Check pending status happens only when the table is loading with ENFORCE NO
option.
It means the load utility didn't perform constraint checking.
COPY PENDING
A state in which, an Image Copy on a table needs to be taken, In this status, the
table is available only for queries. You cannot update this table. To remove the
COPY PENDING status, you take an image copy or use REPAIR utility.
In copypend status... you cannot edit a table.....only u can run queries on that
table..not update
If the tablespace is in Copy pending status and you dont want to take image copy ,
then you can use REPAIR utility or execute following db2 command to bring the
status of tablespace to RW
Code:
This command will reset all the pending states and change the status of the
tablespace to RW .
CHECK PENDING
6
When a table is LOADed with ENFORCE NO option, then the table is left in CHECK
PENDING status. It means that the LOAD utility did not perform constraint checking.
while in Check pending status. you can edit or load table by giving ENFORCE NO
option...
2) Check Pending staus - Run the Check data for those tablespace and the
Tablespace status changes from chkp to RW.
-805 shows Bind problem, Please rebind your program in the correct instance and
make sure you give the correct DBRM library name so that your bind JCL picks up
DBRM from there
SQLCODE Overview
• If SQLCODE = 100, "no data" was found. For example, a FETCH statement
returned no data because the cursor was positioned after the last row of the
result table.
• New with DB2 V8, when DB2 processes a multiple row FETCH statement, the
contents of SQLCODE is set to +100 if the last row in the table has been
returned with the set of rows.
7
SQLCODE - Successful SQL Execution
SQL Return Code +100 ROW NOT FOUND FOR FETCH, UPDATE OR DELETE, OR
THE RESULT OF A QUERY IS AN EMPTY TABLE.
Suggestion: If expecting data, verify WHERE clause for accuracy and
completeness.
SQL Return Code +117 THE NUMBER OF INSERT VALUES IS NOT THE SAME AS
THE NUMBER OF OBJECT COLUMNS.
Suggestion: Correct SQL statement to provide only one value for each column in
the table.
SQL Return Code +304 A VALUE WITH DATA TYPE data-type1 CANNOT BE
ASSIGNED TO A HOST VARIABLE BECAUSE THE VALUE IS NOT WITHIN THE RANGE
OF THE HOST VARIABLE IN POSITION position-number WITH DATA TYPE data-type2.
Suggestion: Verify DCLGEN host variable definitions are current with DB2 catalog
table/view attributes.
SQL Return Code +347 THE RECURSIVE COMMON TABLE EXPRESSION name MAY
CONTAIN AN INFINITE LOOP.
Suggestion: Verify predicate in the SQL WHERE clause of the form "counter_col <
constant" or "counter_col < :hostvar".
SQL Error Code -117 THE NUMBER OF VALUES ASSIGNED IS NOT THE SAME AS
THE NUMBER OF SPECIFIED OR IMPLIED COLUMNS.
Suggestion: Provide one value for each column in the table.
SQL Error Code -150 THE OBJECT OF THE INSERT, DELETE, OR UPDATE
STATEMENT IS A VIEW, SYSTEM-MAINTAINED MATERIALIZED QUERY TABLE, OR
TRANSITION TABLE FOR WHICH THE REQUESTED OPERATION IS NOT PERMITTED.
Suggestion: Be certain to specify base DB2 table/view names for INSERT
statements.
8
SQL Error Code -180 THE DATE, TIME OR TIMESTAMP VALUE value IS INVALID.
Suggestion: Verify the data value is in the correct range and value type.
SQL Error Code -305 THE NULL VALUE CANNOT BE ASSIGNED TO OUTPUT HOST
VARIABLE NUMBER position-number BECAUSE NO INDICATOR VARIABLE IS
SPECIFIED.
Suggestion: Add null indicator variable to SELECT statement in the format of
"column:hostvarind".
SQL Error Code -501 THE CURSOR IDENTIFIED IN A FETCH OR CLOSE STATEMENT
IS NOT OPEN.
Suggestion: Correct logic in application program to OPEN the cursor before the
FETCH or CLOSE statement.
SQL Error Code -530 THE INSERT OR UPDATE VALUE OF FOREIGN KEY constraint-
name IS INVALID.
Suggestion: Ensure that INSERT row for DB2 PARENT table is completed before
INSERT row in CHILD table.
9
SQL Error Code -551 auth-id DOES NOT HAVE THE PRIVILEGE TO PERFORM
OPERATION operation ON OBJECT object-name.
Suggestion: Contact the support DBA to GRANT the needed privilege.
SQL Error Code -803 AN INSERTED OR UPDATED VALUE IS INVALID BECAUSE THE
INDEX IN INDEX SPACE indexspace-name CONSTRAINS COLUMNS OF THE TABLE SO
NO TWO ROWS CAN CONTAIN DUPLICATE VALUES IN THOSE COLUMNS. RID OF
EXISTING ROW IS Xrid.
Suggestion: Verify DB2 INDEX and, if needed, change the statement to an
UPDATE.
SQL Error Code -911 THE CURRENT UNIT OF WORK HAS BEEN ROLLED BACK DUE
TO DEADLOCK OR TIMEOUT. REASON reason-code, TYPE OF RESOURCE resource-
type, AND RESOURCE NAME resource-name.
Suggestion: Review DB2 Master Log to find process holding DB2 locks. Consider
adding additional COMMITs to program holding the DB2 resource.
10
SQL Error Code -922 AUTHORIZATION FAILURE: error-type ERROR. REASON
reason-code.
Suggestion: Connection to DB2 has failed due authority for USER or PLAN. Contact
DBA to check DB2 authorizations.
SQL Error Code -927 THE LANGUAGE INTERFACE (LI) WAS CALLED WHEN THE
CONNECTING ENVIRONMENT WAS NOT ESTABLISHED. THE PROGRAM SHOULD BE
INVOKED UNDER THE DSN COMMAND.
Introduction
Job Control Language (or JCL) specifies how programs are executed on the
mainframe. JCL functions are the interface between the programs and the operating
system. Since JCL has the ability to define data set names, parameters and system
output devices the individual programs can be flexible in their use because these
items are not hard coded in the programs. Without the need for re-compiling, the
same program may be used to access different data sets and behave differently
based on parameters specified in JCL
A JCL source member consists of a file of 80-byte, fixed-length records. The records
(or JCL statements) are written using positions 1-71. Position 72 is reserved for
continuation, a space character indicates no continuation and a non-space
character indicates the next statement will be a continuation of the current
statement.. A JCL statement starts with two slashes in positions 1 to 2. The JCL
specifies a jobname and can contain one or more steps. Each step will execute a
program or procedure (PROC). Comments statements may be added to the JCL
using //* in positions 1 to 3. Every JCL member must begin with a '"Job Card" that
specifies the job name and other information about how the job will execute. The
JCL is completed by using '//' in positions 1 and 2 or when the last statement is
processed.
11
Every JCL member (or JOB) you write will require a JOB statement (or JOB card) to
identify the job. This must be the first statement in each job. Since the JOB card is a
JCL statement it must start with a '//' (two slashes) in positions 1-2. The following is
a sample JOB statement.
....:....1....:....2....:....3....:....4....:....5....:....6....:....7..
// MSGLEVEL=(1,1),NOTIFY=USERID
Note: The preceding JOB statement is continued across two statements. The length
of the text is 72 bytes. Remember, a non-space in position 72 indicates a
continuation.
The job name should be in positions 3-n (for a maximum of eight characters)
followed by a space.
The job name is specified first, in this example the job name will be SIMOJOB1. The
key-word JOB is specified to indicate this is the JOB statement or Job Card.
The job class is specified by using "CLASS=" key word. This information is used to
tell the system how the job is to be run. Jobs will be scheduled and will run under
control of a predefined class as determined by the job initiator. The job class may
determine the priority of the job and how long it will be allowed to run. If the job
12
initiator is already running a job then the current job request may be placed in a job
queue and have to wait until the initiator is free.
The MSGCLASS=x is used to specify where the job output will be directed. The
output classes are predefined and vary from site to site. Two are the normal
defaults are as follows.
A Normal system printing and all output listings sent to the default system
printer.
0 Hold output in the queue and allow job output to be viewed on-line through
the TSO outlist facility.
1 The system prints all JCL statements, JES2, or JES3 control statements,
the procedure statements, and IEF653I messages which show the values assigned
to symbolic parameters in procedure statements.
2 The system prints only JCL statements and JES2 and JES3 control
statements.
y 0 The system prints only JCL messages. It prints JES and operator
messages only if the job abnormally terminates.
1 The system prints JCL messages and any JES and operator messages.
If you want to be notified when the job has finished then use the "NOTIFY=" key
word. The NOTIFY parameter must specify a valid userid.
A Comment Statement
13
//* THIS IS A JCL COMMENT STATEMENT...
Note: The text for the comment should not go past position 71. Remember, a non-
space in position 72 indicates a continuation.
A job step defines the program to run and is created by using the EXEC statement.
There may be one step or many steps within a job. The step name should be in
positions 3-n (for a maximum of eight characters) followed by a space. The following
is an example of a JCL statement that defines a step within a job and executes a
program.
The preceding example defines the step name as STEPID01. The "EXEC" keyword
identifies the statement as a job step definition. The "PGM=" keyword and
parameter specifies the program to be executed. (i.e. EXECute ProGraM). The
program to be executed is IEFBR14.
The preceding example defines the step name as STEPID02. The "EXEC" keyword
identifies the statement as a job step definition. The next parameter specifies the
PROC (or procedure) to be executed.
Defining the Data Sets used by a job step requires a Data Definition (or DD)
statement. A simple DD statement requires a DDNAME, a Data Set Name (or DSN)
and a Disposition (or DISP) keyword.
14
//* A Sample format for a DD statement ...
//ddname DD DSN=data.set.name,DISP=(status,normal-termination-
disp,abnormal-termination-disp)
In the preceding example the ddname in the JCL DD statement corresponds to the
name used in the COBOL SELECT statement. The DSN= keyword and parameter
specifies the fully-qualified MVS Data Set Name. The DISP= keyword and parameter
specifies the disposition as follows.
DISPostion
status Description
OLD The dataset exists and this job step has exclusive use of the dataset.
SHR The dataset exists and other users and jobs can access the dataset, this is
the default
MOD The dataset should be kept and new records will be appended to the end of
the dataset. The dataset may or may not exist. If it does not exist then a data set
will be created.
normal-termination-disp Description
CATLG Places the entry in the system catalog or user catalog. For a NEW data
set this is the default.
UNCATLG Deletes the entry from the system catalog or user catalog.
abnormal-termination-disp Description
DELETE Indicates that the data set is to be deleted at the end of a job step.
CATLG Indicates that the system should place an entry in the system or user
catalog.
15
UNCATLG Indicates that the system is to delete the entry in the system or user
catalog.
//QSAM0080 DD DSN=SIMOTIME.DATA.QSAM0080,DISP=SHR
In the preceding example the COBOL program will read QSAM0080 and the DD
statement will map to the file specified in the DSN parameter
(SIMOTIME.DATA.QSAM0080).
The following is an example and will vary at each mainframe location depending on
the system hardware and software configuration. The important items on the
following is the DISP and DCB information.
//SQADB512 DD DSN=SIMOTIME.DATA.SQADB512,DISP=(NEW,CATLG,DELETE),
16
// STORCLAS=MFI,
// SPACE=(TRK,5),
// DCB=(RECFM=FB,LRECL=512,BLKSIZE=5120,DSORG=PS)
DISPostion Description
DELETE If request abnormally terminates then delete the data set if it exist.
DCB Description
RECFM Record Format, in this example the record format is Fixed Block (FB).
It is possible to process more than one data set as a single data set by
concatenating the DD statements.
//QSAM0080 DD DSN=SIMOTIME.DATA.FILE0001,DISP=SHR
// DD DSN=SIMOTIME.DATA.FILE0002,DISP=SHR
// DD DSN=SIMOTIME.DATA.FILE0003,DISP=SHR
17
SELECT QSAM0080-FILE
ASSIGN to QSAM0080
ORGANIZATION is SEQUENTIAL
In the preceding example the COBOL program will read QSAM0080 and the DD
statements will map the three files (FILE0001, FILE0002 and FILE0003) as one file.
The program's initial read will get the first record from FILE0001 and will not get an
End-of-File condition until the last record of FILE0003 is processed.
//REPORT1 DD SYSOUT=A
//REPORT2 DD SYSOUT=*
In the preceding example the REPORT1 output will be directed to SYSOUT=A which
is usually the system printer. The REPORT2 output will be directed to the location
specified in the MSGCLASS of the JOB statement. If MSGCLASS=0 then REPORT2
output will be directed to SYSOUT=0 which is usually placed in the JES Output
Queue for a specified period of time (such as 3 days) before being purged.
if the ddname is SYSOUT (i.e. //SYSOUT ...) and SYSOUT=* then the job class will be
the same as that specified in the MSGCLASS in the job statement. Since the ddname
is SYSOUT the DISPLAY in a COBOL program will be directed to the location specified
in the MSGCLASS of the JOB statement. If MSGCLASS=0 then REPORT2 output will
be directed to SYSOUT=0 which is usually placed in the JES Output Queue for a
18
specified period of time (such as 3 days) before being purged. The following is a
sample JCL statement with SYSOUT as the DD name.
//SYSOUT DD SYSOUT=*
In the preceding example the text string "This is a test..." will be routed to the JES
output queue.
The use a a DD statement with a DUMMY parameter will allow a program to run if a
data set does not exist. The following example show a DD DUMMY statement.
//QSAM0080 DD DUMMY
SELECT QSAM0080-FILE
ASSIGN to QSAM0080
ORGANIZATION is SEQUENTIAL
19
The following shows the COBOL statements for the open, read and close of the
QSAM0080 data set (i.e. sequential file).
...
read QSAM0080-FILE.
...
close QSAM0080-FILE
In the preceding example the OPEN will be successful, the first READ will return an
End-of-File return code and the close will be successful.
The two techniques use to pass information (a Parameter) from JCL to a program
are as follows.
Technique Description
via SYSIN This technique requires SYSIN statement followed by the parameter to
be placed in the JCL. The COBOL program requires an "ACCEPT parameter from
SYSIN" to be coded in the COBOL program. If the SYSIN statement is missing in the
JCL the ACCEPT will ABEND with a "File not found" message. To avoid this it will be
necessary to use a "//SYSIN DD DUMMY" statement in the JCL when a parameter is
not being passed.
The following two section describe parameter-passing in more detail. Simply click
on one of the following items to learn more or download a set of sample programs
that describe how to pass a parameter string from JCL to a COBOL program.
20
To pass a parameter from JCL to a program requires the use of the "PARM="
keyword with the EXEC statement. The following JCL statement shows an EXEC
statement without a parameter defined.
//* *******************************************************************
//*
The following JCL statement shows an EXEC statement with a parameter defined by
using the "PARM=" keyword. Notice the comma immediately after the program
name. The parameter following the "PARM=" keyword requires the apostrophes if
the text string contains space characters.
//* *******************************************************************
//*
To pass a parameter from SYSIN to a program requires the use of DD statement for
SYSIN. The following JCL statement is required if no parameter is passed.
//* *******************************************************************
21
//*
//SYSIN DD DUMMY
The following JCL statements show what is required to pass information via SYSIN.
//* *******************************************************************
//*
//SYSIN DD *
//*
JCL defines how a job is executed on the mainframe. A job may perform many steps
or execute many programs in order to produce the requested information or output.
If a segment of JCL is used repeatedly it may be coded once as a PROC (or JCL
Procedure) and then used by many different steps within the job. There are two
approaches to defining and using PROC's.
Instream Proc
22
The following is an example of an instream PROC that is used three times when the
JOB is executed. The job step that calls the instream PROC will provide the name of
the PDS to be created via the &DSNAME substitution value.
//* *******************************************************************
//* *
//* *******************************************************************
//*
//*
//* The JCL member executes the instream PROC called PDSCRTP3 and
//* passes a fully qualified data set name (DSN) via the symbolic name
//*
//*********************************************************************
//* The instream PROC for creating a PDS. The Data Set Name (&DSNAME)
//*
//PDSCRTP3 PROC
//TEMPLIB1 DD DISP=(NEW,CATLG),DSN=&DSNAME,
// STORCLAS=MFI,
23
// SPACE=(TRK,(45,15,50)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PO)
// PEND
//*
//* *******************************************************************
//*
// SET DSNAME=SIMOTIME.DEMO.TEMP01
//*
//* *******************************************************************
//*
//*
//* *******************************************************************
//*
//*
Additional information about the use of JCL and PROCs may be found in the
JCLPRC01.HTM document.
JCL substitution is mainly used when a repeatable process is used many times but
needs the ability to behave differently based on variable information passed from
the job that is excuting the process. Simply click on one of the following items to
learn more or download sample JCL that describe how to use variable substitution
within JCL.
24
The SET Statement
The SET statement lets you set the values of symbolic parameters within a JCL or
PROC member. Simply click on one of the following items to learn more or download
sample JCL that describes the SET statement.
This section provides examples of how to use INCLUDE and JCLLIB statements in
JCL. The following from the JES output shows the statements and the substituted
values.
20 //*
21 //* *******************************************************************
22 //*
23 // JCLLIB ORDER=SIMOTIME.PDS.JCLINC
24 // INCLUDE MEMBER=JCLINCI1
##*
##* *******************************************************************
## SET HLQ01=SIMOTEST
## SET HLQ02=TEMP
25 //* *******************************************************************
28 //*
30 //TESTFILE DD DSN=&HLQ01..&HLQ02..TESTFILE,DISP=(MOD,DELETE,DELETE),
SUBSTITUTION - DSN=SIMOTEST.TEMP.TESTFILE,DISP=(MOD,DELETE,DELETE),
25
31 // STORCLAS=MFI,
32 // SPACE=(TRK,5),
33 // DCB=(RECFM=V,LRECL=80,DSORG=PS)
34 //*
Simply click on one of the following items to learn more or download a sample set of
programs.
If programs are not stored in the libraries predefined for the operating systems then
it will be necessary to specify the location of the programs. For example, if program
are located in a private library or a test library then use STEPLIB and/or JOBLIB to
tell the system the location of the programs.
STEPLIB and JOBLIB require a DD statement that defines the names of the Load
Libraries that are searched to find and load the program. As the names imply the
STEPLIB statement applies only to an individual job step, the JOBLIB statement
applies to the whole job. If you specify both then the STEPLIB statement will
override what is specified by the JOBLIB statement but only for the individual step.
A JOBLIB statement must be specified after the Job statement and before any job
steps (or EXEC statements). The STEPLIB must be specified after the EXEC PGM
statement of the job step.
//JOBLIB DD DSN=SIMOTIME.DEVL.LOADLIB1,DISP=SHR
//*
//*
//*
26
//STEP0300 EXEC PGM=PROGRAM3
//STEPLIB DD DSN=SIMOTIME.DEVL.TEMPLIB1,DISP=SHR
//*
Conditional JCL
27
EMPLYEE
EXEC SQL
DECLARE DSNXXX.EMPLOYEE
( EMPID CHAR(10) NOT NULL,
EMPNAME CHAR(30) NOT NULL,
DEPARTMENT CHAR(2) NOT NULL,
SALARY DECIMAL(10,2) NOT NULL,
DESIGNATION CHAR(4) NOT NULL )
END-EXEC.
EXEC SQL
INCLUDE < copybookname >
END-EXEC.
01 EMPOYEE-RECORD.
05 HV-EMPID PIC X(10).
05 HV-EMPNAME PIC X(30).
05 HV-DEPARTMENT PIC X(2).
05 HV-SALARY PIC S9(8)V99 COMP-3.
05 HV-DESIGNATION PIC CHAR(4).
28
STEP 3. Include SQLCA as follows in WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
What is SQLCA?
.........
EXEC SQL
SELECT SALARY
INTO :HV-SALARY
FROM EMPLOYEE
WHERE EMPNAME = 'XXXXXXX'
END-EXEC.
IF SQLCODE = 0
ELSE
END-IF.
....
....
Here SQLCODE = 0 means, sql ran sucessfully without any issues. Hence
we are displaying the HV-SALARY into the spool.
29
If SQLCODE NOT = 0 , there is issue in executing the sql statement.
INTRODUCTION
30
STEP 1 - DB2 PRECOMPILE Process
The DB2 Precompile performs three functions. First, it checks the SQL in
the program for errors. Second, it adds working storage areas and source
code compatible statements that are used to invoke DB2. One of the working
storage areas contains a literal "timestamp" called a consistency token. Finally, all
of the SQL statements are extracted from the program source and placed into a
member called the DataBase Request Module, or DBRM, which also contains the
consistency token.
31
STEP 2 - COMPILE
The modified source from the precompile is then compiled. The code is
checked for errors, and a compiled version of the code is created.
STEP 3 - LINK-EDIT
The compiled code is link-edited along with statically called source language
and DB2 run-time modules to create a Load Module. Imbedded in this module is the
same consistency token that was generated in the precompile. If multiple DB2
programs are statically linked together, the resulting load module contains a
consistency token for each one.
The bind process reads the DBRM that was created in the precompile and prepares
an access path to the data. This access path, along with the consistency token, is
stored in the DB2 catalog as a Package. Every Package is bound into a Package List,
or Collection. The name of the Collection is specified by the PACKAGE parameter. A
Collection is a group of Packages that are included in one or more Plans. The
QUALIFIER parameter of the bind is used to direct the SQL to the specific set of DB2
objects (tables, views, aliases or synonyms) qualified by this name.
When COBOL-DB2 Program executes, the plan name must be specified. For
online CICS programs, the plan name is specified by Tran ID in the Resource Control
Table (RCT). For a batch program, the plan name is specified in the SYSTSIN input
DD. The packages for all DB2 programs executed under a Tran ID or batch job step
must be included in collection bound into this plan. When the first SQL statement
of each program is executed, DB2 searches the collections within the plan using the
package name and consistency token from the load module. If an exact match
is not found, a -805 SQLCODE is returned.
1) In JCL sort card sum fields = none for eliminating duplicates. How can I retrieve
only duplicates?
You could use SORTXSUM dataset and XSUM option in SUM FIELDS.
32
it will possible by the icetool
//toolin dd *
select from(in) to(dups) on(1,6,ch) alldups discard(nondups)
/*
dups--duplicate elements
nondups--non duplicate elements
2) How will you make sure that your SELECT query retrieves only one row always?
Using primary key in the where statement of the select would give only one row.
ex: declare cursor x for select y,z from emp where x=y for fecth 1 row only.
this serves the purpose.
3) DISTINCT is used for eliminating duplicate rows in DB2. How can retrieve all the
duplicates (A sample query is highly appreciated)?
4) I have a sort requirement like 5 records. In that 4 are same and 1 is different. I
want to get only that 1 record. How? Anyone have an idea about "EQUALS" in sort
card?
33
//SYSOUT DD SYSOUT=*
//SYSOUD DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,2,CH,A)
SUM FIELDS=NONE,XSUM
//
Bind the program 'program name' as the member part of the application plan 'plan
name' or * Correct the collection id in the PKLIST and bind the application plan 'plan
name' or * Set the current package set special register correctly or * Put the correct
'location name' in the CURRENTSERVER of the BIND command and bind the
application plan 'plan name' or * Connect to the correct RDB name or * Correct the
location id in the PKLIST and bind the application plan 'plan name' or * Bind the
DBRM of the version of the application program to be executed
well this error comes when there is mismatch b/w the Load of a prog. and the bind
of the prog .
so its better to check whether which load module u r using in ur job ., along with
which plan u r using .
or if u r not certain abt the load module.
better do a compile bind again .
-805 will occur when you run your program without binding it properly in to your
test region. Some times it may happen that you compiled your program but there
are still some SQL errors which compiler cant locate that time during binding it fails.
And when you try to run this program you will hit by ?805. The other common
reason is that when you compile your program but forget to bind it, then while
execution it will fetch the old edition and due to time stamp mismatch you get ?
805.
If you want to check the time stamp just go to your LOADLIB library and check for
the time stamp. Now if this time stamp not matches with the timestamp in
SYSIBM.SYSPACKAGES for that program then you will get ?805.
Explaination :
34
name.consistency token' if the current package set special register is blank for the
local program execution) that has not been found due to one or more or the
following reasons:
*The program 'program name' has not been bound as the member part of the
application plan 'plan name'
*The 'collection id' in the PKLIST was not correct when the application plan 'plan
name' was bound
*The current package set special register was not set correctly
*The 'location name' in the CURRENTSERVER was not correct when the application
plan 'plan name' was bound,
*The application was not connected to the proper location
*The location id in the package list was not correct when the application 'plan name'
was bound
*The DBRM of the version of the application program being executed was not
bound.
Resolution :
Based on the above reasons, the programmer can perform the following operations
to correct the error.
* Bind the program 'program name' as the member part of the application plan
'plan name'
* Correct the collection id in the PKLIST and bind the application plan 'plan name'
* Set the current package set special register correctly
* Put the correct 'location name' in the CURRENTSERVER of the BIND command and
bind the application plan 'plan name'
* Connect to the correct RDB name
* Correct the location id in the PKLIST and bind the application plan 'plan name'
* Bind the DBRM of the version of the application program to be executed
8)I have written program, ?PROGRAM-ID. ADD. Saved this particular program in a
PDS as member name TEST. Will it work or throw any error?
for eighth when the program name in pds and the id if they are not same then i
think it will give an error.
9) I am compiling a COBOL db2 program suddenly my Db2 brought down what will
happen?
35
Regarding The above Question. U will get "DB2 CONNECTION INTERNAL ERROR" and
the error number is "-924"
During compilation process it will check whether all the columns in the sql
statements are present in Dclgen or not.
During compilation it will not check DB2 system Catlogues(sysibm.syscolumns).
At compilation time Db2 is not at all required.
During Bind process it will check as per DB2 Tables
for example :
you can use a column in sql statement which does not exist in Db2 at all.
but it should be Dclgen....thats it .....
your compilation job will be fine
but your bind job fails
for tenth question Z/OS is the operating system which is an advanced one
like MVS.
IMS - PROCOPT
G get
I insert
R get and replace
D get and delete
A get, insert, replace, and delete
P required if the D command code is to be used
O do not perform integrity checks for read only processing
must be specified as GO, GON, GONP, GOT, GOTP, or GOP
N do not abend on invalid pointer, return GG instead
must be specified as GON, GONH, or GONP
36
T same as N but automatically retries before returning GG
must be specified as GOT, GOTH, or GOTP
E enable exclusive use by online program
L load
GS get in ascending sequence (hsam only)
LS load in ascending sequence (hidam or hdam only)
H use high speed sequential processing
Can i ISSUE GNP call first with out using GN OR GU call before?
No you can't.
It returns staus code as "GP" - No parentage established.
During PCB generation, you can use five options of the PROCOPT parameter (in the
DATABASE macro) to indicate to IMS™ whether your program can read segments in the
hierarchy, or whether it can also update segments. From most restrictive to least restrictive, these
options are:
Related Reading: For a thorough description of the processing options see, IMS Version 9:
Utilities Reference: System.
37
Processing options provide data security because they limit what a program can do to the
hierarchy or to a particular segment. Specifying only the processing options the program requires
ensures that the program cannot update any data it is not supposed to. For example, if a program
does not need to delete segments from a database, the D option need not be specified.
When an application program retrieves a segment and has any of the just-described processing
options, IMS locks the database record for that application. If PROCOPT=G is specified, other
programs with the option can concurrently access the database record. If an update processing
option (R, I, D, or A) is specified, no other program can concurrently access the same database
record. If no updates are performed, the lock is released when the application moves to another
database record or, in the case of HDAM, to another anchor point.
The following locking protocol allows IMS to make this determination. If the root segment is
updated, the root lock is held at update level until commit. If a dependent segment is updated, it
is locked at update level. When exiting the database record, the root segment is demoted to read
level. When a program enters the database record and obtains the lock at either read or update
level, the lock manager provides feedback indicating whether or not another program has the
lock at read level. This determines if dependent segments will be locked when they are accessed.
For HISAM, the primary logical record is treated as the root, and the overflow logical records are
treated as dependent segments.
When using block-level or database-level data sharing for online and batch programs, you can
use additional processing options.
• E option
• GO option
• N option
• T option
• GOx and data integrity
Related Reading:
• For a special case involving HISAM delete byte with parameter ERASE=YES
see, IMS Version 9: Administration Guide: Database Manager.
• For more information on database and block-level data sharing, see IMS
Version 9: Administration Guide: System.
E option
With the E option, your program has exclusive access to the hierarchy or to the segment you
use it with. The E option is used in conjunction with the options G, I, D, R, and A. While the E
program is running, other programs cannot access that data, but may be able to access segments
that are not in the E program's PCB. No dynamic enqueue by program isolation is done, but
dynamic logging of database updates will be done.
38
GO option
When your program retrieves a segment with the GO option, IMS does not lock the segment.
While the read without integrity program reads the segment, it remains available to other
programs. This is because your program can only read the data (termed read-only); it is not
allowed to update the database. No dynamic enqueue is done by program isolation for calls
against this database. Serialization between the program with PROCOPT=GO and any other
update program does not occur; updates to the same data occur simultaneously.
If a segment has been deleted and another segment of the same type has been inserted in the
same location, the segment data and all subsequent data that is returned to the application may be
from a different database record.
N option
When you use the N option with GO to access a full-function database or a DEDB, and the
segment you are retrieving contains an invalid pointer, IMS returns a GG status code to your
program. Your program can then terminate processing, continue processing by reading a
different segment, or access the data using a different path. The N option must be specified as
PROCOPT=GON, GON, or GONP.
T option
When you use the T option with GO and the segment you are retrieving contains an invalid
pointer, the response from an application program depends on whether the program is accessing
a full-function or Fast Path database.
For calls to full-function databases, the T option causes DL/I to automatically retry the operation.
You can retrieve the updated segment, but only if the updating program has reached a commit
point or has had its updates backed out since you last tried to retrieve the segment. If the retry
fails, a GG status code is returned to your program.
For calls to Fast Path DEDBs, option T does not cause DL/I to retry the operation. A GG status
code is returned. The T option must be specified as PROCOPT=GOT, GOT, or GOTP.
39
GOx and data integrity
For a very small set of applications and data, PROCOPT=GOx offers some performance and
parallelism benefits. However, it does not offer application data integrity. For example, using
PROCOPT=GOT in an online environment on a full-function database can cause performance
degradation. The T option forces a re-read from DASD, negating the advantage of very large
buffer pools and VSAM hiperspace for all currently running applications and shared data. For
more information on the GOx processing option for DEDBs, see IMS Version 9: Utilities
Reference: System.
Answer
Always remember that IMS calls are based on POSITION. You can NEVER go
backwards - only forwards. You can re-position yourself with a GU. The first thing I
would do is to load your key for the prod segment into the prod-cat-cid. I would then
issue a GU - not a GN. Behind the scenes - with a GN - even a qualified, IMS reads
each prod segment until it satisfies the loaded key. With a GU, IMS looks at the CI
40
splits to determine where the key may be. (Just in case you wanted to know). I hope
you are checking for successful call when you issue the call for the prod. If you don't
get it, you should have some sort of error routine for the result of your call
depending on what the status code is - anything other the spaces or GE (not found)
will be very bad.
01 PROD-ID-SSA.
05 FILLER PIC X(9) VALUE 'PRODUCT ('.
05 FILLER PIC X(10) VALUE 'PRODCAID ='.
05 PROD-CAT-CID PIC X(5).
05 FILLER PIC X VALUE ')'.
Once you have the parent, you will need to retrieve the child - or children. Do you
have a key for the order? How do you know which order you are looking for? You
cannot issue a qualified call under the root unless you know. You need to explain
what you are looking for. It cannot and must not be a qualified call unless you know.
Remember that the reason this is a child segment is that there can be 1 to many.
01 ORDR-ID-SSA.
05 FILLER PIC X(9) VALUE 'ORD ('. ---------------------------you will need to make this
spaces unless you know the order number.....
05 FILLER PIC X(10) VALUE 'ORDPID ='.
05 ORDR-PID-VALUE PIC 9(5).
05 FILLER PIC X VALUE ')'.
41
The following status codes may be returned after processing an IMS call
blank
AA
AB
AC
AD
AF
AH
AI
AJ
AK
AL
batch program has issued a ROLS, ROLB, or SETS call and either the system log
does not reside on disk or dynamic backout is not specified
42
AM
AO
AP
a CHKP function issued a transaction oriented BMP or a message call has more
than 4 parameters
AT
AU
AY
logical terminal name found in a response alternate PCB has more than one
physical terminal assigned
AZ
A1
logical terminal name specified incorrectly in I/O area for a CHNG call
A2
A3
A4
security violation
A5
43
A6
A7
A8
ISRT function issued to a response alternate PCB must follow ISRT to I/O PCB and
these statements are reversed
A9
BA
call not completed because data is not available, operations by current call up to
this error have been backed out
BB
call not completed because data is not available, operations since last commit
point have been backed out
CA
CB
CC
CD
program does not have authority to execute a command listed in this CMD
function
CE
IMS rescheduled a message as a result of a call with the function GU since the
last CMD call
44
CF
CG
CH
CI
IMS rescheduled a message as a result of a call with the function GU since the
last CMD call and message scheduled before IMS was started
CJ
IMS rescheduled a message as a result of a call with the function GU since the
last CMD call and message retrieved by GU originated from an AOI user exit
CK
CL
IMS rescheduled a message as a result of a call with the function GU since the
last CMD call, message scheduled before IMS was started, and message retrieved
by GU originated from an AOI user exit
CM
exception response occurred when executing a command issued via CMD call
CN
DA
DJ
DX
45
DLET violated delete rule for segment
FA
FC
FD
resource deadlock
FE
FF
MSDB did not contain free space when ISRT was issued
FG
FLD function received non blank status code in FSA and program has used all of
buffer pool
FH
DEDB was not accessible when database call was issued or commit point was
reached
FI
FM
FN
FP
FS
46
FT
FV
FW
GA
call completed successfully but higher level crossed for GN or GNP call
GB
GC
GD
GE
GG
GK
call completed successfully but different segment type on same level retrieved
for GN or GNP call
GL
GP
II
47
attempt to insert a segment with a duplicate key
IX
LB
LC
LD
LE
hierarchical sequence in DBD does not match that in the segment to be loaded
MR
NA
NE
NI
NO
NU
QC
QD
48
GN requested but no more message segments exist
QE
QF
QH
RA
RC
RX
SA
SB
SC
TA
TC
TE
TG
49
no PSB scheduled for program
TH
TI
TJ
TL
TN
TO
TP
PROCOPT invalid
TQ
TR
TY
TZ
UC
during batch processing, a checkpoint record was written to the utility control
facility (UCF) dataset
UR
50
during batch processing, IPL is restarted under UCF
US
UX
VI
GNP call
A GNP with an unqualified SSA sequentially retrieves the dependent segment occurrences of the
segment type you have specified under the established parent.
A GNP with a qualified SSA describes to IMS the segment you want retrieved or the segment that
is to become part of the hierarchic path to the segment you want retrieved. A qualified GNP
describes a unique segment only if it is qualified on a unique key field and not a data field or a
non unique key field.
A GNP with multiple SSAs defines the hierarchic path to the segment you want. If you specify
SSAs for segments at levels above the established parent level, those SSAs must be satisfied by
the current position at that level. If they cannot be satisfied using the current position, a GE
status code is returned and the existing position remains unchanged. The last SSA must be for a
segment that is below the established parent level. If it is not, a GP status code is returned.
Multiple unqualified SSAs establish the first occurrence of the specified segment type as part of
the path you want. If some SSAs between the parent and the requested segment in a GNP call are
missing, they are generated internally as unqualified SSAs. This means that IMS includes the
first occurrence of the segment from the missing SSAs as part of the hierarchic path to the
segment you have requested.
51