Full Material Salesforce
-
Upload
anonymous-fh8wqzv -
Category
Documents
-
view
130 -
download
18
description
Transcript of Full Material Salesforce
1
OM Technologies
2
OM Technologies
3
OM Technologies
4
OM Technologies
COBOL
COBOL stands for Common Business Oriented Language. It is the primary programming language used for developing applications on Mainframe. Even today, COBOL is treated as the BEST programming language for developing business applications.
5
OM Technologies
6
OM Technologies
Source Computer : It specifies the computer model used for compilation. Object Computer : It specifies the computer model used for execution. File-Control : All the files used in the program are declared here. I-O Control : Checkpoints on file data are set here.
7
OM Technologies
File section : All file related fields are declared here Working-Storage section : All temporary fields are declared here Linkage section : Fields used to pass data between programs are declared here
8
OM Technologies
9
OM Technologies
10
OM Technologies
11
OM Technologies
12
OM Technologies
13
OM Technologies
Note : V and S can be used with only numeric data type PICTURE clause is used to identify the data type and data length of a field.
Level Number It is used to describe the data hierarchy. We can use level numbers 01 to 49 and special level numbers 66, 77 and 88.
14
OM Technologies
15
OM Technologies
01 EMP-DET.. 05 EMP-ID PIC X(10) VALUE ‘E22’. 05 EMP-NAME. 07 FN PIC A(2) VALUE ‘RAM’. 07 MN PIC A(2) VALUE ‘PRASAD’. 07 LN PIC A(2) VALUE ‘K’. 05 EMP-SAL PIC 9(5) VALUE 25000. 05 DEPT-ID PIC X(2) VALUE ‘D1’. 05 EMP-JOIN-DT. 09 YYYY. 11 CC PIC X(2) VALUE ’20’. 11 YY PIC X(2) VALUE ’11’. 09 MM PIC X(2) VALUE ‘02’. 09 DD PIC X(2) VALUE ‘27’.
16
OM Technologies
17
OM Technologies
18
OM Technologies
19
OM Technologies
20
OM Technologies
21
OM Technologies
22
OM Technologies
23
OM Technologies
24
OM Technologies
25
OM Technologies
26
OM Technologies
27
OM Technologies
28
OM Technologies
29
OM Technologies
PROCEDURE DIVISION. STRING FN DELIMITED BY ‘ ‘, MN DELIMITED BY SPACE, LN INTO FULL-NAME WITH POINTER WS-PNT END-STRING. DISPLAY FULL-NAME. We can get the count of characters passed to FULL-NAME by subtracting initial WS-PNT value from the final WS-PNT value.
30
OM Technologies
PROCEDURE DIVISION. UNSTRING FULL-NAME DELIMITED BY SIZE INTO FN, MN, LN END-UNSTRING.
31
OM Technologies
32
OM Technologies
33
OM Technologies
34
OM Technologies
35
OM Technologies
36
OM Technologies
37
OM Technologies
38
OM Technologies
39
OM Technologies
40
OM Technologies
41
OM Technologies
42
OM Technologies
43
OM Technologies
44
OM Technologies
45
OM Technologies
46
OM Technologies
47
OM Technologies
48
OM Technologies
49
OM Technologies
50
OM Technologies
51
OM Technologies
52
OM Technologies
53
OM Technologies
JCL (Job Control Language)
• JCL acts as an interface between Operating System and Programming language.
• JCL is the carrier of the program and the data to OS and output from OS.
Uses of JCL
• It is used to compile & execute COBOL programs.
• It is used to create & delete datasets (PDS & PS), GDGs and VSAM clusters.
• It is used to copy data from one dataset to anther dataset.
• It is used to sort & merge the file data.
Important statements in JCL
JCL has 3 important statements – JOB, EXEC and DD statements
• A JOB can have maximum 255 EXEC statements.
• An EXEC statement can have maximum 255 DD statements.
Sample JCL
//FSS182EX JOB ‘A123’, ’OMTECH’, CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1), PRTY=15,
TYPRUN=SCAN,
// NOTIFY=&SYSUID, REGION=6M, TIME=(30,10), COND=(4,LT), RESTART=STEP2
//JOBLIB DD DSN=FSS182.OMT.LOADLIB1, DISP=SHR
//STEP1 EXEC PGM=RPTPGM, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-
2011’
//STEPLIB DD DSN=FSS182.OMT.LOADLIB2, DISP=SHR
//DISK1 DD DSN=FSS182.OMT.POL.FILE, DISP=SHR
//DISK2 DD DSN=FSS182.OMT.POL.RPT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=133, BLKSIZE=1330, RECFM=FB, DSORG=PS),
// UNIT=DASD/TAPE, VOL-SER=V123,
// SPACE=(TRK,(5,6,0),RLSE),
// RETPD=1234 / EXPDT=12046
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
P111
JB
/*
//
JCL Coding Sheet
12 (3 - 10) (12 - 15) (16/17 - 72) (73 - 80)
// NAME OPERATION OPERANDS USER COMMENTS
54
OM Technologies
//JOBNAME JOB Positional &
// Keyword Parameters
//STEPNAME EXEC
//DDNAME DD
NAME Parameter is used to identify a JCL statement.
OPERATION specifies the type of JCL statement.
OPERANDS can be classified into Positional & Keyword parameters.
• Positional parameters are mandatory and must be specified in a particular order
only
• Keyword parameters are optional and if specified can be in any order.
JOBLIB
It specifies the load library in which all the STEPs’ program load modules are referred.
That is, JOBLIB is applicable to all the steps.
Sample JCL
//FSS182EX JOB ‘A123’, ’OMTECH’, CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1), PRTY=15,
// NOTIFY=&SYSUID, REGION=6M, TIME=(30,10), COND=(4,LT),
// TYPRUN=SCAN, RESTART=STEP2
//JOBLIB DD DSN=FSS182.OMT.LOADLIB1, DISP=SHR
//STEP1 EXEC PGM=PROG1, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-2011’
//STEP2 EXEC PGM=PROG2, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-2011’
//STEP3 EXEC PGM=PROG3, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-2011’
//
STEPLIB
It specifies the load library in which ONLY a particular STEP’s program load module is referred.
That is, STEPLIB is applicable to only a particular the step.
Sample JCL
//FSS182EX JOB ‘A123’, ’OMTECH’, CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1), PRTY=15,
// NOTIFY=&SYSUID, REGION=6M, TIME=(30,10), COND=(4,LT),
// TYPRUN=SCAN, RESTART=STEP2
//JOBLIB DD DSN=FSS182.OMT.LOADLIB1, DISP=SHR
//STEP1 EXEC PGM=PROG1, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-2011’
//STEP2 EXEC PGM=PROG2, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-
2011’
//STEPLIB DD DSN=FSS182.OMT.LOADLIB2, DISP=SHR
//STEP3 EXEC PGM=PROG3, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-
2011’
//
Note: When both JOBLIB and STEPLIB are specified, then first STEPLIB is referred and if load
module is not found, then JOBLIB is referred and if still not found, then System-defined load
libraries are referred and if still not found, abends with S806 abend code.
S806 – No Active Load Module found.
POSITIONAL Parameters in JOB statement: Accounting Information, Programmer Name.
Keyword Parameters in JOB statement : CLASS, PRTY, MSGCLASS, MSGLEVEL, NOTIFY, TYPRUN, RESTART, REGION, COND, TIME.
55
OM Technologies
Accounting Information : It specifies the account code for which billing is done for executing
programs on
Mainframe. All the job information i.e., the CPU time consumed, amount charged, start date &
end date can be seen in JESMSGLG of SPOOL.
Programmer Name : It specifies the coder name who has written the JCL.
Example :
//FSS182EX JOB ‘A123’, ’OMTECH’, CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1)
//FSS182EX JOB , ’OMTECH’, CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1)
//FSS182EX JOB ‘A123’, ,CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1)
//FSS182EX JOB , , CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1)
CLASS It categorizes jobs based on factors like CPU consumption time and CPU resource
utilization.
Class can have the range of values A – Z and 0 – 9.
Class=A Job can take 5 min for execution.
Class=B Job can take 10 min for execution.
Class=C Job can take 1 hour for execution.
Class=0 Job can utilize maximum CPU resources.
Class=1 Job can utilize minimum CPU resources.
PRTY : It sets the priority for the job execution. PRTY has the range of values – 0 to 15.
The highest the PRTY value, the first preference it is given for execution.
The Least the PRTY value, the least preference it is given for execution.
Note 1 : When two jobs are submitted, the job which is submitted first is executed first.
Note 2 : When two jobs are submitted at same time, the jobs are executed based on CLASS
parameter.
Note 3 : When two jobs are submitted at same time and with same CLASS parameter value, then
jobs are
executed based on PRTY value.
Note 4 : When two jobs are submitted at same time and with same CLASS and PRTY, then both
the jobs are
cancelled.
RESTART : It is used to start the job execution from a particular step(i.e., abended step).
Syntax : RESTART=STEP2
//FSS182EX JOB ‘A123’, ’OMTECH’, CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1), PRTY=15,
// NOTIFY=&SYSUID, REGION=6M, TIME=(30,10), COND=(4,LT),RESTART=STEP2
//STEP1 EXEC PGM=PROG1
//STEP2 EXEC PGM=PROG2
//STEP3 EXEC PGM=PROG3
//
MSGCLASS : MSGCLASS specifies the output device to which messages need to be sent.
MSGCLASS can have a range of values A-Z. 0-9.
MSGCLASS=A Printer
MSGCLASS=X SPOOL
MSGCLASS=0 TOOL1 (Eg : JOBH)
56
OM Technologies
MSGCLASS=0 TOOL2 (Eg : AXIOM)
MSGLEVEL
TYPRUN
NOTIFY:
It specifies the USER ID to which the STATUS NOTIFICATION is sent about the successful or
unsuccessful execution of job.
Status Notification can be known by MaxCC.
When MaxCC = 0/4, it indicates successful execution of job.
Other than 0/4, it indicates unsuccessful execution of job.
NOTIFY=&SYSUID will substitute the USER ID with which User has logged in. So, the status
notification will be sent to the same User ID.
57
OM Technologies
Suppose User has logged in with FSS141 and specified NOTIFY=FSS142, then Status notification is
sent to FSS142 but the SPOOL information remains with FSS141.
REGION:
REGION parameter specifies the amount of workspace required for a job or step’s execution.
REGION is specified in Kilo or Mega Bytes and in ODD quantities.
Eg : REGION=5M / 3K
Maximum REGION space can be allocated by specifying REGION=0K or 0M.
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X,REGION=5M
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEP2 EXE C PGM=PROG2,REGION=3K
//STEP3 EXE C PGM=PROG3
NOTE 1 : REGION specified in JOB is applicable by all the steps in the job.
NOTE 2 : REGION specified in STEP is applicable to only that particular step.
NOTE 3 : REGION specified in both JOB and STEP, then value specified in JOB overrides that of
STEP.
TIME
TIME parameter specifies the amount of time to be allocated for a job or step’s execution.
TIME=(minutes,seconds)
TIME=(10,20)
TIME=10
TIME=(,20)
Maximum TIME can be allocated by specifying TIME=1440
TIME= NOLIMIT
TIME=MAX
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X,TIME=(10,30)
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEP2 EXE C PGM=PROG2,TIME=5
//STEP3 EXE C PGM=PROG3
NOTE 1 : TIME specified in JOB is applicable to all the steps in the job.
NOTE 2 : TIME specified in STEP is applicable to only that particular step.
NOTE 3 : TIME specified in both JOB and STEP, then value specified in JOB overrides that of
STEP.
COND
When a job is executed, all the steps execute irrespective of their previous sterps execute
successfully or unsuccessfully.
COND parameter is used to control the execution of steps.
When COND specified is false, the step executes.
When COND specified is true, the step is bypassed.
Note : COND is applicable for all the steps except the first step.
58
OM Technologies
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X,COND=(4,LT)
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEP2 EXE C PGM=PROG2,COND=(8,LE)
//STEP3 EXE C PGM=PROG3
NOTE 1 : COND specified in JOB is applicable to all the steps except the first step.
NOTE 2 : COND specified in STEP is applicable to only that particular step.
NOTE 3 : COND specified in both JOB and STEP, then value specified in STEP overrides that
of JOB.
Scenario 1: Never execute the step i.e., even the step executes successfully or unsuccessfully, do
not execute the step. So, the COND specified must be true for all return codes of previous step.
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEP2 EXE C PGM=PROG2,COND=( 0 , LE)
Or
//STEP2 EXE C PGM=PROG2,COND=( 4095 , GE)
Scenario 2: Always execute the step i.e., even the step executes successfully or unsuccessfully,
always execute the step. So, the COND specified must be false for all return codes of previous
step.
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEP2 EXE C PGM=PROG2,COND=( 0 , GT)
Or
//STEP2 EXE C PGM=PROG2,COND=( 4095 , LT)
Scenario 3:Execute the step ONLY when the previous step executes successfully.
So, the COND specified must be false for return codes 0 and 4 only.
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEP2 EXE C PGM=PROG2,COND=( 4 , LT)
OR
//STEP2 EXE C PGM=PROG2,COND=( 8 , LE)
Scenario 4:Execute the step ONLY when the previous step executes unsuccessfully.
59
OM Technologies
So, the COND specified must be false for return codes 8 to 4095.
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEP2 EXE C PGM=PROG2,COND=( 8 , GT)
OR
//STEP2 EXE C PGM=PROG2,COND=( 4 , GE)
EXEC Statement
Positional Parameters in EXEC statement :
PGM
Keyword Parameters in EXEC statement :
REGION
TIME
COND
PARM
PGM specifies the program name to be executed.
PARM parameter is used to pass the data from JCL to COBOL. We can pass a maximum of 100
characters only.
PARM parameter is specified in the EXEC statement as follows :
//STEP1 EXEC PGM=RPTPGM, PARM=’23-07-2011’
Data specified in PARM parameter is received into COBOL program as follows :
DATA DIVISION.
LINKAGE SECTION.
01 LS-PARM.
10 LS-PARM-LEN PIC S9(4) COMP.
10 LS-PARM-TEXT PIC X(100).
PROCEDURE DIVISION USING LS-PARM.
DISPLAY LS-PARM-TEXT.
Sample JCL
//FSS182EX JOB ‘A123’, ’OMTECH’, CLASS=A, MSGCLASS=A, MSGLEVEL=(1,1), PRTY=15,
// NOTIFY=&SYSUID, REGION=6M, TIME=(30,10), COND=(4,LT),
// TYPRUN=SCAN, RESTART=STEP2
//JOBLIB DD DSN=FSS182.OMT.LOADLIB1, DISP=SHR
//STEP1 EXEC PGM=RPTPGM, REGION=3K, TIME=(10,20), COND=(8,LE), PARM=’23-07-2011’
//STEPLIB DD DSN=FSS182.OMT.LOADLIB2, DISP=SHR
//DISK1 DD DSN=FSS182.OMT.POL.FILE, DISP=SHR
//DISK2 DD DSN=FSS182.OMT.POL.RPT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=133, BLKSIZE=1330, RECFM=FB, DSORG=PS),
// UNIT=DASD/TAPE, VOL-SER=V123,
// SPACE=(TRK,(5,6,0),RLSE),
// RETPD=1234 / EXPDT=12046
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
P111
JB
/*
60
OM Technologies
//
DD Statement
DD statement specifies the characteristics of a dataset.
Keyword Parameters in DD statement :
DSN
DISP
DCB
UNIT
SPACE
VOL-SER
RETPD
EXPDT
DSN :
Status
NEW : It is specified for a new dataset and the corresponding OPEN Mode is OUTPUT.
SHR : It is specified for an existing dataset and the corresponding OPEN Mode is INPUT.
OLD : It is specified for an existing dataset and the corresponding OPEN Mode can be INPUT,
OUTPUT, I-O.
MOD : It is specified for a new or existing dataset and the corresponding OPEN Mode is EXTEND.
CATLG : When a new dataset is created, the dataset information is stored in the System Catalog.
UNCATLG : It removes the dataset information from the System Catalog but the dataset still
remains in the system catalog.
61
OM Technologies
KEEP : When KEEP is specified for a new dataset, the dataset is created but its information is not
stored in System Catalog. So, each time the dataset is to be accessed, user needs to specify the
Volume Serial Number.
Note : KEEP must always be specified for existing datasets as follows :
DISP=(SHR,KEEP,KEEP)
DISP=(OLD,KEEP,KEEP)
DELETE : It deletes the dataset from hard disk and it information from system catalog.
Examples :
DISP = (NEW,CATLG,DELETE)
DISP = (OLD,CATLG,UNCATLG)
By Default,
DISP = NEW will take DISP=(NEW,DELETE,DELETE)
DISP = SHR will take DISP=(SHR,KEEP,KEEP)
DISP = OLD will take DISP=(OLD,KEEP,KEEP)
DISP = MOD will take DISP=(MOD,CATLG,DELETE)
UNIT parameter specifies the storage device on which the dataset is to be created.
UNIT =DASD/SYSDA stores dataset on Hard Disk.
DASD - DIRECT ACCESS STORAGE DEVICE
SYSDA - SYSTEM DIRECT ACCESS
UNIT =TAPE stores dataset on TAPE device.
TAPE is an external device made of magnetic strips used to take backup of data.
VOL-SER specifies the volume serial number of the memory volume on which dataset is to be
created.
VOL-SER=V134
SPACE parameter specifies the amount of memory to be allocated for a dataset.
SPACE is allocated
SPACE=((Primary Quantity, Secondary Quantity, Directory Blocks),RLSE)
First Primary Quantity is allocated.
If not sufficient, then Secondary Quantity is allocated.
If still not sufficient, then again Secondary Quantity is allocated and so on upto 15 extents.
Eg : SPACE=(1000,(10,20),RLSE)
SPACE=(BLKS,(10,20,5),RLSE)
SPACE=(TRKS,(5,10))
SPACE=(CYL,(10,5),RLSE)
DCB (Data Control Block)
DCB specifies the characteristics of a dataset.
DCB=(LRECL=100,BLKSIZE=10000,RECFM=FB,DSORG=PS)
LRECL : It specifies the record length of the file.
LRECL = 100
BLKSIZE : It specifies the Size of the block in which records are stored.
BLKSIZE must always be an exact multiple of LRECL.
BLKSIZE=10000
62
OM Technologies
Number of records per block = BLKSIZE / LRECL
= 10000 / 100 = 100
When READ statement executes, then one block of records are retrieved from hard disk to
buffer.
This will reduce the number of I/O operations, thereby improving the program efficiency.
RECFM : It specifies the record format of the file.
There are two types of files – FIXED and VARIABLE files.
RECFM = FB / VB --- Maximum records are stored per block.
RECFM = F / V --- Only one record is stored per block.
RETPD (Retention Period)
It specifies the life of a dataset.
RETPD = dddd where dddd indicate number of days.
Eg : RETPD = 1345 indicates after 1345 days, the dataset will be deleted.
EXPDT (Expiration Date)
It specifies the life of a dataset.
EXPDT = YYddd where YY indicates year.
Eg : EXPDT = 14054 indicates after 54 days in 2014, the dataset will be deleted.
Sample Execution JCL
//JOB1 JOB ‘A123,’KEERTHI’,CLASS=A,MSGCLASS=X, MSGLEVEL=(1,1),COND=(4,LT)
//JOBLIB DD DSN=FSS046.KEERTHI.LOADLIB1,DISP=SHR
//STEP1 EXE C PGM=PROG1
//STEPLIB DD DSN=FSS046.RAMESH.LOADLIB,DISP=SHR
//DISK1 DD DSN=FSS141.POL.FILE,DISP=SHR
//DISK2 DD DSN=FSS141.JB.FILE,DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=150,BLKSIZE=0,RECFM=FB),
// SPACE=(TRK,(10,5,0),RLSE)
//DISK3 DD DSN=FSS141.JS.FILE,DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=150,BLKSIZE=0,RECFM=FB),
// SPACE=(TRK,(10,5,0),RLSE)
//STEP2 EXE C PGM=RPTPGM
//DISK1 DD DSN=FSS141.JB.FILE,DISP=SHR
//DISK2 DD DSN=FSS141.JB.RPT,DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=133,BLKSIZE=0,RECFM=FB),
63
OM Technologies
// SPACE=(TRK,(10,5,0),RLSE)
//STEP3 EXE C PGM=RPTPGM,COND=(4,LT,STEP1)
//DISK1 DD DSN=FSS141.JS.FILE,DISP=SHR
//DISK2 DD DSN=FSS141.JS.RPT,DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=133,BLKSIZE=0,RECFM=FB),
// SPACE=(TRK,(10,5,0),RLSE)
JCL UTILITIES
• IEBGENER
• IEBCOPY
• IEFBR14
• IDCAMS
• SORT
IEBGENER : It is used to copy data from one PS to another PS.
//JOB1 JOB - - - - -
//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD DSN=FSS141.POL.FILE,DISP=SHR
//SYSUT2 DD DSN=FSS141.POL.FILE.BACKUP,
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=100,BLKSIZE=1000,RECFM=FB),
// SPACE=(CYL,(10,5),RLSE)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
IEBCOPY : It is used to copy data from one PDS to another PDS.
//JOB1 JOB - - - - -
//STEP1 EXEC PGM=IEBCOPY
//SYSUT1 DD DSN=FSS141.OMT.SOURCE,DISP=SHR
//SYSUT2 DD DSN=FSS141.RAMU.SOURCE,
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=100,BLKSIZE=1000,RECFM=FB,DSORG=PO),
// SPACE=(CYL,(10,5,5),RLSE)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
COPY INDD=SYSUT1, OUTDD=SYSUT2
/*
To copy ONLY selected members from one PDS to another PDS.
//SYSIN DD *
COPY INDD=SYSUT1, OUTDD=SYSUT2
SELECT MEMBER=(PROG3,PROG66,PROG78)
/*
To EXCLUDE ONLY selected members from copying.
//SYSIN DD *
COPY INDD=SYSUT1, OUTDD=SYSUT2
EXCLUDE MEMBER=(PROG3,PROG66,PROG78)
/*
64
OM Technologies
IEFBR14 : It is used to create & delete datasets.
//JOB1 JOB - - - - -
//STEP1 EXEC PGM=IEFBR14
//SYSUT1 DD DSN=FSS141.OMT.SOURCE,
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=100,BLKSIZE=1000,RECFM=FB,DSORG=PO),
// SPACE=(CYL,(10,5,4),RLSE)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
Deleting datasets
//SYSUT1 DD DSN=FSS141.POL.FILE,
// DISP=(OLD,DELETE,DELETE)
//SYSUT1 DD DSN=FSS141.POL.FILE,
// DISP=(MOD,DELETE,DELETE)
IDCAMS : It is used to delete one or more datasets.
//JOB1 JOB ------
//STEP1 EXEC PGM=IDCAMS
//SYSIN DD *
DELETE ‘FSS141.OMT.SOURCE’ -
DEL ‘FSS143.POL.FILE’
/*
SORT : It is used to sort the data in file.
To copy data from one file to another file
//JOB1 JOB - - - - -
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN=FSS142.POL.FILE,DISP=SHR
//SORTWK01 DD UNIT=DASD,SPACE=(TRK,(2,2),RLSE)
//SORTWK02 DD UNIT=DASD,SPACE=(TRK,(2,2),RLSE)
//SORTWK03 DD UNIT=DASD,SPACE=(TRK,(2,2),RLSE)
//SORTOUT DD DSN=FSS142.POL.FILE.SORTED,
// DISP=(NEW,CATLG,DELETE),
// DCB=*.SORTIN,
// SPACE=(TRK,(10,10),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
/*
To sort file in ascending or descending order
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
/*
SORT FIELDS = (1,10,CH,A) --------- SORT CARD
CH Alphanumeric
65
OM Technologies
N Numeric
BI Binary
PD Packed Decimal
SORTIN is the INPUT DD name for the SORT utility
SORTOUT is the OUTPUT DD name for the SORT utility.
SORTWRK files are required to do the sorting process before processing the data into SORTOUT.
To copy only selected records based on condition
//SYSIN DD *
SORT FIELDS = COPY
INCLUDE COND = (23,5,CH,EQ,C ‘JB’)
/*
To exclude the records based on the condition
//SYSIN DD *
SORT FIELDS = COPY
OMIT COND = (23,5,CH,EQ,C ‘JB’)
/*
To eliminate duplicate records and to copy only unique records
//SYSIN DD *
SORT FIELDS = (23,5,CH,A)
SUM FIELDS = NONE
/*
To COPY duplicate records
//SYSIN DD *
SORT FIELDS = (23,5,CH,A)
SUM FIELDS = NONE,XSUM
/*
//SORTXSUM DD DSN=FSS142.POL.FILE.DUP,DISP=OLD
To split a file data into multiple datasets
//JOB1 JOB - - - - -
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN=FSS142.POL.FILE,DISP=SHR
//SORTWK01 DD UNIT=DASD,SPACE=(TRK,(2,2),RLSE)
//SORTWK02 DD UNIT=DASD,SPACE=(TRK,(2,2),RLSE)
//SORTWK03 DD UNIT=DASD,SPACE=(TRK,(2,2),RLSE)
//SORTOF01 DD DSN=FSS142.JB.FILE,
// DISP=(NEW,CATLG,DELETE),
// DCB=*.SORTIN,
// SPACE=(TRK,(10,10),RLSE)
//SORTOF02 DD DSN=FSS142.JS.FILE,
// DISP=(NEW,CATLG,DELETE),
// DCB=*.SORTIN,
// SPACE=(TRK,(10,10),RLSE)
//SYSIN DD *
SORT FIELDS = COPY
OUTFIL FNAMES=SORTOF01,INCLUDE = (20,10,CH,EQ,C ’JB’)
OUTFIL FNAMES=SORTOF02,INCLUDE = (20,10,CH,EQ,C ‘JS’)
/*
GDG is a collection of similar datasets i.e., structurally and functionally same.
66
OM Technologies
Uses of GDG
1. GDGs are used to take backup of data.
2. GDGs automate the process of deleting & creating datasets once the limit is reached.
3. We need not change the JCL for changing the file names.
GDG has two components.
1. GDG Base
2. GDG Generation
GDG Base is created using the utility IDCAMS as follows :
//JOB1 JOB - - - - - - - -
//STEP1 EXEC PGM=IDCAMS
//SYSIN DD *
DEFINE GDG( -
NAME(FSS141.REL.DAILY.GDG) -
LIMIT(7) -
NOEMPTY/EMPTY -
NOSCRATCH/SCRATCH)
/*
NAME parameter specifies the GDG Base name
LIMIT parameter specifies the maximum number of generations that a GDG Base can hold.
Note : We can specify a maximum LIMIT of 255
Upon reaching the limit,
NOEMPTY Uncatalogs oldest generation.
EMPTY Uncatalogs all generations
SCRATCH Deletes the uncataloged generations.
NOSCRATCH Does not delete any generations.
In a week, 7 GDG Generations are created as follows :
67
OM Technologies
Weekly Backup of 7 Daily Files :
//JOBW JOB - - - - - - - -
//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD DSN=FSS141.REL.DAILY.GDG.G0001V00,DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG.G0002V00,DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG.G0003V00,DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG.G0004V00,DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG.G0005V00,DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG.G0006V00,DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG.G0007V00,DISP=SHR
//SYSUT2 DD DSN=FSS141.REL.WEEKLY.GDG(+1),
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=100,BLKSIZE=0,RECFM=FB),
// SPACE=(TRK,(10,5),RLSE)
//JOBW JOB - - - - - - - -
//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD DSN=FSS141.REL.DAILY.GDG(-6),DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG(-5),DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG(-4),DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG(-3),DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG(-2),DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG(-1),DISP=SHR
// DD DSN=FSS141.REL.DAILY.GDG(0),DISP=SHR
//SYSUT2 DD DSN=FSS141.REL.WEEKLY.GDG(+1),
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=100,BLKSIZE=0,RECFM=FB),
// SPACE=(TRK,(10,5),RLSE)
Procedures
PROCEDURE is a set of reusable JCL statements. We cannot use * and JOBLIB in a PROC definition. Procedures are of two types.
1. INSTREAM PROCEDURE 2. CATALOGED PROCEDURE
68
OM Technologies
Instream Procedures
//JOB1 JOB --------- //JOBLIB DD DSN=FSS142.KEERTHI.LOADLIB,DISP=SHR //STEP1 EXEC PGM=PROG1 //PROC1 PROC //STEPA EXEC PGM=RPTPGM //DISK1 DD DSN=FSS146.JB.FILE,DISP=SHR //DISK2 DD DSN=FSS146.JB.RPT, // DISP=(NEW,CATLG,DELETE), // DCB=(LRECL=133,BLKSIZE=0,RECFM=FB), // SPACE=(TRK,(10,5,0),RLSE) //SYSIN DD DSN=FSS145.CNTL.CARD,DISP=SHR // PEND //STEP2 EXEC PROC1 //STEP3 EXEC PROC=PROC1 //STEP4 EXEC PGM=PROG2 //STEP5 EXEC PROC1 // Instream Procedures Vs Catlagoed Procedure
Symbolic Parameters
Symbolic parameters are used to substitute DD statement parameter values. They are identified by using single ‘&’. Default values must be specified in PROC definition. When Symbolic parameter values are specified in both JOB and PROC, then JOB values are considered.
69
OM Technologies
Overriding Parameters These parameters are used to override the existing values for EXEC statement parameters. Syntax : Stepname.Parameter = New-value For COND parameter, COND.Stepname = New-value
70
OM Technologies
Db2 Database
Database management system (DBMS) is a software package that manages data stored in databases. IBM’S Database 2 , commonly referred to as DB2, was made available in 1983 as RDBMS concept. Prior to DB2, IBM developed a HDBMS product IMS DB.
Data on Mainframe is stored in two ways : 1. Files 2. Database
DB2 is the RDBMS developed by IBM for storing and accessing heavy data. RDBMS – Relational Data Base Management System. RDBMS allows data access to entities by establishing the following relationships : ONE TO MANY MANY TO ONE MANY TO MANY
Advantages of database over files : 1. Database supports high volume of data storage whereas files support low volume of data
storage. 2. Database provides data security at various levels whereas files do not. 3. Accessing database data is easy as compared to files where programming is required. 4. Database supports data concurrency & locking. 5. Database avoids data redundancy.
When DB2 S/W is installed on the Mainframe, a system space and user space are created. In the SYSTEM SPACE, default tables called DB2 catalog tables & DB2 directory tables are stored. DB2 Catalog tables store the information of the user created database objects. SYSIBM.SYSTABLESPACES store tablespaces’ information. SYSIBM.SYSTABLES store tables’ information. SYSIBM.SYSCOLUMNS store columns’ information. SYSIBM.SYSVIEWS store views’ information. DB2 Directory tables store the information about the physical memory locations of database objects. In the USER SPACE, user created database objects like tablespaces, tables, views, synonyms, stored procedures, etc.
71
OM Technologies
Table: Table is the entity where we can store the data in the form of rows and columns. Storage grp: It is a set of memory volumes allocated to the table space. Data in table spaces are stored in the form of the tables. Page: Page is an amount of space in the table space which is used to transmit the data from system memory to buffer. Page size can be 4k, 8k….32k. Page can have maximum of 127 rows. Table spaces are again 3 types. Simple Segmented Partitioned
Simple table space: In this type of TS, a page can hold more than one table’s data. Segmented table space: In this type of TS, a page can hold ONLY one table’s data. Partitioned table space: In this type of TS, a set of pages are grouped into a partition and only specific data is stored in each partition. Using partitioned table space, amount of memory to be scanned is reduced, thereby improves the DB2 performance. Data types in DB2 and COBOL DB2 COBOL SMALL INT 2 bytes S9(4) COMP INT 4 Bytes S9(9) COMP CHAR (N) N Bytes X(n) VARCHAR (N) (N+2) Bytes 01 VAR-FIELD 49 LEN PIC S9(4) COMP. 49 TEXT PIC X(N). DECIMA S9(M-N)V9(N) COMP-3 DATE 10 Bytes X(10) [DD-MM-YYYY] TIME 8 Bytes X(08) [HH.MN.SS] TIMESTAMP 26 Bytes X(26) [DD-MM-YYYY- HH.MN.SS-NNNNN] DB2 data is accessed using SQL queries. DDL CREATE, ALTER , DROP DML INSERT, UPDATE, DELETE, SELECT DCL GRANT, REVOKE
72
OM Technologies
CREATE: It is used to create database objects. Creating a database: CREATE DATABASE DB123. Creating a table space: CREATE TABLE SPACE TS123 STORGROUP3 PAGESIZE 16K SEGMENTED IN DB123. Creating a table: CREATE TABLE EMP_TBL (EMP_ID INT NOT NULL, EMP_NAME CHAR(30), EMP_DEPT SMALL INT, EMP_SAL DECIMAL(11,2), EMP_ADDR VARCHAR(50), EMP_JOIN_DT DATE NOT NULL WITH DEFAULT, EMP_JOIN_TM TIME, TRANS_TS TIMESTAMP, PRIMARY KEY (EMP_ID), ON DELETE CASCADE) IN DB123.TS123 Constraint is a mechanism to control the data in the tables.
1. Primary Key. 2. NULL Constraints 3. Referential Integrity
Primary Key: It is used to uniquely identify a row in the table. When primary key constraint set on a column it does not allow duplicate or null values. Null value : It is an unknown value assigned to a column when no value is specified. Null Constraint: By default, any column is nullable (allows null values). Not Null Constraint: It does not allow null values to be stored and so a value must be specified. Not Null with Default: If no value is specified then instead of storing null value it stores a default value based on the data type. Note: For SMALL INT INT and DECIMAL Zeroes are the default values. For CHAR Spaces are the default values. For DATE Current date is the default value. For TIME Current time is the default value. For TIMESTAMP Current time stamp is the default value.
73
OM Technologies
Referential Integrity: It controls the data in the parent and child table Foreign Key: It is used to build the relationship between the tables. It must be a primary key of the table and when we use this in the other table then it becomes as a foreign Key. Table in which it is primary key then it is called Parent table and the table in which it is foreign key then it is called child table. RI rules :
1. Insert Rule 2. Update Rule 3. Delete Rules
- ON DELETE CASCADE - ON DELETE RESTRICT - ON DELETE SET NULL INSERT RULE : It says before inserting a row with new foreign key value, insert it first into parent table. UPDATE RULE : It says before updating a row with new foreign key value, update it first in the parent table. DELETE Rules :
1. ON DELETE CASCADE : It says when a parent table row is deleted, the corresponding rows in all child tables also get deleted.
2. ON DELTE RESTRICT : It says when a parent table row with corresponding rows in child tables is to be deleted, then a restriction is applied. So, first, delete the child table rows and then parent table row.
3. ON DELETE SET NULL : It says when a parent table row is deleted, the foreign key values for the corresponding rows in all child tables are set to NULL.
ALTER: It is used to modify the database objects. Syntax: ALTER EMP_TBL ADD EMP_DOB DATE This column will add at the last in the table EMP_TBL. Note: A column can be added only as the last column in the table. If we need to add the column in between the columns then we need to drop and create new table. We can change the data types and data lengths. ALTER EMP_TBL SET EMP_SAL DECIMAL (11,2) DECIMAL(13,2) We can change the data types, increase/decrease the data length if a table is empty. But if the table is non empty we can only increase the data length. DROP: Drop is used to permanently delete a data object in a database. Syntax: DROP TABLE EMP_TBL DROP VIEW V_EMP_TBL DML(Data Manipulation Language) INSERT: It is used to insert a new row into the table. Only one row at a time. INSERT INTO EMP_TBL
74
OM Technologies
VALUES (0314,’RAMESH’…) If all the values are specified, then column names need not be specified. INSERT INTO EMP_TBL (EMP_ID, EMP_NAME) VALUES (0314,’RAMESH’) UPDATE: It is used to modify the existing data in the table. UPDATE EMP-TBL SET EMP-SAL=EMP-SAL+1000 The above code will update all EMP-SAL column values in the table. UPDATE EMP-TBL SET EMP-SAL=EMP-SAL+1000 WHERE DEPT=’D1; WHERE clause is used to specify a condition based on which rows selective. DELETE: It is used to delete the rows from the table. DELETE FROM EMP-TBL, it will delete all the rows. DELETE FROM EMP-TBL WHERE DEPT = ‘D1’ SELECT: It is used to retrieve the rows from the table. SELECT * FROM EMP-TBL The above query retrieves all the rows and columns. SELECT EMP-ID,EMP-SAL FROM EMP-TBL This query retrieves all the rows with column EMP-ID & EMP-SAL. SELECT * FROM EMP-TBL WHERE DEPT = ‘D1’ This query will retrieve all the rows with DEPT value ‘D1’. SELECT EMP-ID FROM EMP-TBL WHERE EMP-SAL BETWEEN 10000 AND 300000 It issues a permissions on DML commands GRANT: To provide access or permissions on data base objects to the users. Syntax: GRANT INSERT,SELECT ON EMP_TBL TO FSS141, GRP1. GRANT ALL ON EMP_TBL TO FSS142, FSS156 [ REVOKE: To remove the authorizations or permissions. REVOKE INSERT ON EMP_TBL FROM FSS141, GRP1. REVOKE ALL ON EMP_TBL FROM FSS142, FSS156
75
OM Technologies
SQLCA SQLCA is SQL Communication Area. It is the communication are between COBOL and DB2. SQLCA is used in the program as follows : EXEC SQL INCLUDE SQLCA END-EXEC. The above statement is resolved during DB2 pre-compilation as follows : 01 SQLCA. 03 SQLAID PIC 03 SQLCODE PIC 03 SQLWARN PIC 03 SQLERR PIC 03 SQLSTATE PIC SQLCODE is used to know the status of a Db2 statement. If SQLCODE is 0 or +ve, DB2 execution is successful If SQLCODE is -ve, DB2 execution is unsuccessful SQLCODE = 0 Successful and row found SQLCODE = 100 Successful but row not found
76
OM Technologies
DB2 Compilation Process & BIND Parameters
DB2 Program preparation involves the following steps : 1. Coding the program.
2. Pre-compilation
3. BIND
4. Compilation
5. LINK-EDIT
6. Execution
77
OM Technologies
78
OM Technologies
79
OM Technologies
80
OM Technologies
81
OM Technologies
CURSORS
What is the need of cursor? When a SELECT query retrieves more than one row, the program will abend with SQLCODE -811 since it cannot hanlde multiple rows at a time. Eg : SELECT EMP_SAL FROM EMP_TBL WHERE DEPT_ID = ‘D6’ Then how to handle multiple rows in the program? Ans: Using Cursor. What is a Cursor ? Ans: Cursor is a pointer to a row in the resultant table. Cursor Life Cycle :
Declaring cursor. Opening the cursor. Fetching the cursor. Closing the
cursor.
82
OM Technologies
Closing cursorL:f
Closing the cursor : It used to delete the cursor and the resultant table. Exec SQL Close EMPCUR
83
OM Technologies
END-EXEC
Updateable View A View is said to be Updateable when it satisfies all of the below specified conditions :
1. View must be created on a single table.
84
OM Technologies
2. No DISTINCT, GROUP BY or HAVING must be used. 3. No SUB-QUERIES must be used. 4. No Arithmetic operations must be used. 5. Base Table columns other than View columns must be nullable.
Non-Updateable View A View is said to be Non-Updateable when it does not satisfy any one or all of the below specified conditions : 1. View must be created on a single table. 2. No DISTINCT, GROUP BY or HAVING must be used. 3. No SUB-QUERIES must be used. 4. No Arithmetic operations must be used. 5. Base Table columns other than View columns must be nullable.
Aggregate Functions
These aggregate functions are used to act on a set of column values. 1 MAX : It gives the maximum value from a set of column values. SELECT MAX(EMP_SAL) FROM EMP_TBL 2. MIN : It gives the minimum value from a set of column values. SELECT MIN(EMP_SAL) FROM EMP_TBL 3. SUM : It gives the sum of a set of column values. SELECT SUM(EMP_SAL) FROM EMP_TBL 4. AVG : It gives the average of a set of column values. SELECT AVG(EMP_SAL) FROM EMP_TBL Note : AVG will give an incorrect value when the column has null values. 5. COUNT : It gives the count of column values. SELECT COUNT(EMP_SAL) FROM EMP_TBL It gives the count of column values in the table excluding null values. SELECT COUNT(*) FROM EMP_TBL It gives the count of rows in the table.
GROUP BY
It is used to group a set of similar column values. GROUP BY is mandatory when a combination of non-aggregate and aggregate columns are used. To get the count of employees department wise : SELECT DEPT_ID, COUNT(*) FROM EMP_TBL GROUP BY DEPT_ID To get the count of students class wise : SELECT CLASS, COUNT(*) FROM SCH_TBL GROUP BY CLASS To get the count of students class & section wise : SELECT CLASS, SECTION, COUNT(*) FROM SCH_TBL
85
OM Technologies
GROUP BY CLASS, SECTION
HAVING
It is used to specify a condition which acts on a set of column values. HAVING must always follow GROUP BY clause. Example : SELECT DEPT_ID, COUNT(*) FROM EMP_TBL GROUP BY DEPT_ID HAVING COUNT(*) > 3 SELECT DEPT_ID, COUNT(*) FROM EMP_TBL GROUP BY DEPT_ID HAVING DEPT-ID = ‘D3’
Sub- Queries
There are two types of sub-queries :
1. Non-correlated sub-queries.
2. Correlated sub-queries.
Non-correlated sub-queries : First the Inner Query executes and then based on its result, the Outer query executes. Correlated sub-queries : First the Outer Query executes and for each row of outer query, the inner query executes i.e., first the outer query executes then the inner query.
Non-correlated Sub-queries
First the Inner Query executes and then based on its result, the Outer query executes. Example : To find the 2nd maximum salary SELECT MAX(SAL) FROM EMP_TBL
WHERE SAL < (SELECT MAX(SAL) FROM EMP_TBL)
Example : To find the 3rd maximum salary SELECT MAX(SAL) FROM EMP_TBL
WHERE SAL < (SELECT MAX(SAL) FROM EMP_TBL) WHERE SAL < (SELECT MAX(SAL) FROM EMP_TBL)
86
OM Technologies
Correlated Sub-queries
First the Outer Query executes and for each row of outer query, the inner query executes i.e., first the outer query executes then the inner query. Example : To find the 2nd maximum salary
SELECT E1.SAL FROM EMP_TBL E1 WHERE 1 = (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2
WHERE E2.SAL > E1.SAL)
Example : To find the 3rd maximum salary SELECT E1.SAL FROM EMP_TBL E1
WHERE 2 = (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2 WHERE E2.SAL > E1.SAL) To find the nth maximum salary
SELECT E1.SAL FROM EMP_TBL E1 WHERE n-1 = (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2
WHERE E2.SAL > E1.SAL) Example : To find the 2nd minimum salary SELECT E1.SAL FROM EMP_TBL E1
WHERE 1 = (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2 WHERE E2.SAL < E1.SAL) Example : To find the 3rd minimum salary SELECT E1.SAL FROM EMP_TBL E1
WHERE 2 = (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2 WHERE E2.SAL < E1.SAL) To find the nth minimum salary SELECT E1.SAL FROM EMP_TBL E1
WHERE n-1 = (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2 WHERE E2.SAL < E1.SAL) Example : To get the list of TOP 5 salaries SELECT E1.SAL FROM EMP_TBL E1 WHERE 5 > (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2
WHERE E2.SAL > E1.SAL) To get the list of TOP N salaries SELECT E1.SAL FROM EMP_TBL E1
WHERE n > (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2 WHERE E2.SAL > E1.SAL) Example : To get the list of LEAST 5 salaries SELECT E1.SAL FROM EMP_TBL E1
WHERE 5 > (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2 WHERE E2.SAL < E1.SAL) To get the list of LEAST N salaries
SELECT E1.SAL FROM EMP_TBL E1 WHERE n > (SELECT COUNT(DISTINCT E2.SAL) FROM EMP_TBL E2 WHERE E2.SAL < E1.SAL)
JOINS
87
OM Technologies
JOIN is used to combine columns from more than one table i.e., data can be retrieved from more than one table by joining them on some common columns. Types of Joins :
1. INNER JOIN 2. OUTER JOIN
- LEFT OUTER JOIN - RIGHT OUTER JOIN - FULL OUTER JOIN
88
OM Technologies
89
OM Technologies
UNIONS UNION is used to combine rows from more than one table. For using UNION, the data types and number of columns in both the queries must be same. Column name may be different. SELECT EMP_ID, DEPT_ID FROM DEPT_TBL1 UNION SELECT EMP_ID, DEPT_ID FROM DEPT_TBL2 This will retrieve all the rows from both the tables but only unique rows are retrieved. SELECT EMP_ID, DEPT_ID FROM DEPT_TBL1
UNION ALL SELECT EMP_ID, DEPT_ID FROM DEPT_TBL2
This will retrieve all the rows from both the tables including duplicate rows.
Performance Tuning DB2 Performance Tuning Techniques :
1. By using Indexes 2. By using DB2 utilities – RUNSTAT and REORG 3. By avoiding arithmetic operations in DB2 queries. 4. By using Joins
Index
90
OM Technologies
Index reduces the amount of memory to be scanned, thereby reducing the execution time and hence improves the DB2 performance.
DB2 Utilities
RUNSTAT utility : When it is run, all the statistics about the database objects are collected from DB2 catalog tables.
When RUNSTAT holds the latest information, OPTIMIZER can generate the BEST ACCESS PATH which will inturn improve the DB2 performance. REORG utility : When it is run, the tablespace memory is reorganized i.e., all the data pages are accumulated releasing the unused pages into the free memory.
When REORG reorganizes the data in the tablespace, the amount of memory to be scanned reduces, thereby improving the DB2 performance .
Using JOINs
Normal Query : SELECT EMP_ID, DEPT_ID, DEPT_NUM, DEPT_NAME FROM EMP_TBL, DEPT_TBL WHERE DEPT_ID = DEPT_NUM AND EMP_SAL > 20000 This query retrieves the entire data from both the tables and then applies the WHERE condition.
Query using JOIN
91
OM Technologies
SELECT EMP_ID, DEPT_ID, DEPT_NUM, DEPT_NAME FROM EMP_TBL, JOIN DEPT_TBL ON DEPT_ID = DEPT_NUM WHERE EMP_SAL > 20000 This query retrieves only the filtered data satisfying the ON condition and then applies the WHERE condition.
Since the amount of data to be processed is less using JOINs as compared to normal query, DB2 performance will be good using JOINs.
92
OM Technologies
93
OM Technologies
94
OM Technologies
95
OM Technologies
96
OM Technologies
97
OM Technologies
98
OM Technologies
99
OM Technologies
100
OM Technologies
101
OM Technologies
102
OM Technologies
103
OM Technologies
TYPE: It specifies the type of map to be generated.
TYPE=MAP Only Physical map is generated.
104
OM Technologies
TYPE=DSECT Only Symbolic map is generated.
TYPE=&SYSPARM Both Physical & Symbolic maps are generated.
105
OM Technologies
106
OM Technologies
107
OM Technologies
108
OM Technologies
109
OM Technologies
110
OM Technologies
111
OM Technologies
112
OM Technologies
113
OM Technologies
114
OM Technologies
115
OM Technologies
116
OM Technologies
117
OM Technologies
118
OM Technologies
119
OM Technologies
120
OM Technologies
121
OM Technologies
122
OM Technologies
SDLC & Workflow
Software products are of two types :
1. Generic S/W product
2. Client-specific S/W product
To develop any S/W product, we follow SDLC.
SDLC is a standard methodology used to develop a Quality S/W product.
Workflows for a S/W developer :
1. Development activity - Developing a new S/W application from
scratch.
2. Production Support - Providing support to applications in client
region.
3. Maintenance activity - Modifying functionalities in existing
applications.
4. Enhancement activity- Adding new functionalities in existing
applications.
Phases in SDLC
Development Activity : Any new application has to follow the below phases
in SDLC to get a Quality product.
1. Requirements phase
2. Design phase
3. Build/CUT phase
4. Test phase
5. UAT (User Acceptance Test) phase
6. Implementation
Warranty Support / Post Implementation Support (optional)
123
OM Technologies
Requirement Phase
This is the first phase after the project is initiated.
In this phase, client gives a BRD (Business Requirements Document) to the Service
Provider.
BRD contains the following :
1. About the business process of the client.
2. About the existing applications on which the new application is dependent.
3. About the current business requirements.
Once the BRD is received, analysis is conducted at the Service provider end. Once the
requirements are clearly understood by the service provider, an analysis document is
prepared and sent to client for review. Once client is satisfied with the analysis
document, he gives a sign-off to the Requirements phase.
This analysis is required to ensure Service provider has understood all the requirements or
not.
Design Phase
This is the second phase after the Requirements phase.
In this phase, the business requirements are converted into technical requirements i.e.,
HLD and LLD documents are prepared.
HLD (High Level Design) : This document provides a high level overview of each process
in the application.
Once HLD is signed-off, LLD is prepared.
124
OM Technologies
LLD (Low Level Design) : This document provides a detailed description of each
process in the application.
BUILD/CUT (Coding & Unit Testing)
This is the third phase after the Design phase.
In this phase, developer will be involved in the following tasks :
1. Preparing Unit test cases.
2. Coding programs, jobs, copybooks, BMS maps, etc.
3. Preparing test data for unit testing.
4. Unit testing – Testing of individual programs.
5. Preparing Unit test results.
TEST Phase
This is the fourth phase after the BUILD phase.
In this phase, tester will be involved in the following tasks :
1. Preparing System test cases.
2. System testing – Testing of whole application from end to end.
3. Preparing System test results.
UAT Phase
This is the fifth phase after the TEST phase.
In this phase, client/user will be involved in the following tasks :
125
OM Technologies
1. Preparing test scenarios.
2. User testing – Testing of whole application from end to end by client.
Implementation
This is the sixth phase after the UAT phase.
In this phase, the S/W components (programs, copybooks, jobs, procs, bms maps) are
moved from development into production region.
Warranty Support
This is optional i.e., based on the contract, warranty support is provided for the
developed application. This is also called as Post-implementation Support.
Till the client is used to the application and to resolve any abends, warranty support is
provided.
Production Support
Once the application is handed over to the client, the production support team
oversees the smooth running of business applications.
1. Monitoring batch cycles i.e., monitoring the smooth running of batch jobs.
2. Providing resolutions to the abends.
3. Escalating issues to operations team.
Maintenance Activity
126
OM Technologies
From time to time, the existing applications has to be modifed as per the changing
business rules and strategies.
Enhancement Activity
From time to time, new functionalities must be added to the existing applications for the
new business rules and strategies.