Questions
Questions
com
9. However, if the item being tested is a signed item, then it may contain 0-9,
+ and -.
Q8) How do you define a table/array in COBOL?
A8) ARRAYS.
05 ARRAY1 PIC X(9) OCCURS 10 TIMES.
05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.
Q9) Can the OCCURS clause be at the 01 level?
A9) No.
Q10) What is the difference between index and subscript? -GS
A10) Subscript refers to the array occurrence while index is the displacement (i
n no of bytes) from the
beginning of the
array. An index can only be modified using PERFORM, SEARCH & SET. Need to have i
ndex for a
table in order to
use SEARCH, SEARCH ALL.
Q11) What is the difference between SEARCH and SEARCH ALL? -GS
A11) SEARCH -is a serial search.
SEARCH ALL -is a binary search & the table must be sorted ( ASCENDING/DESCENDING
KEY
clause to be used & data loaded in this order) before using SEARCH ALL.
Q12) What should be the sorting order for SEARCH ALL? -GS
A12) It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want
the search
to be done on an
Page 4 of 260 IBMMAINFRAMES.com
array sorted in descending order, then while defining the array, you should give
DESCENDING
KEY clause. (You
must load the table in the specified order).
Q13) What is binary search?
A13) Search on a sorted array. Compare the item to be searched with the item at
the center. If it matches,
fine else repeat the process with the left half or the right half depending on w
here the item lies.
Q14) My program has an array defined to have 10 items. Due to a bug, I find that
even if the
program access the
11th item in this array, the program does not abend. What is wrong with it?
A14)
Must use compiler option SSRANGE if you want array bounds checking. Default is N
OSSRANGE.
Q15) How do you sort in a COBOL program? Give sort file definition, sort stateme
nt syntax and
meaning. -GS
A15) Syntax: SORT file-1 ON ASCENDING/DESCENDING KEY key.... USING file-2 GIVING
file-3.
USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2
GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.
file-1 is the sort (work) file and must be described using SD entry in FILE SECT
ION.
file-2 is the input file for the SORT and must be described using an FD entry in
FILE SECTION and
SELECT
clause in FILE CONTROL.
file-3 is the out file from the SORT and must be described using an FD entry in
FILE SECTION and
SELECT
clause in FILE CONTROL.
file-1, file-2 & file-3 should not be opened explicitly.
INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the
sort work
file from the input procedure.
OUTPUT PROCEDURE is executed after all records have been sorted. Records from th
e sort work
file must be RETURNed one at a time to the output procedure.
Q16) How do you define a sort file in JCL that runs the COBOL program?
A16) Use the SORTWK01, SORTWK02,..... dd names in the step. Number of sort datas
ets depends on the
volume of data
being sorted, but a minimum of 3 is required.
Q17) What is the difference between performing a SECTION and a PARAGRAPH? -GS
A17)
Performing a SECTION will cause all the paragraphs that are part of the section,
to be performed.
Performing a PARAGRAPH will cause only that paragraph to be performed.
Q18) What is the use of EVALUATE statement? -GS
A18) Evaluate is like a case statement and can be used to replace nested Ifs. Th
e difference between
EVALUATE and
case is that no 'break' is required for EVALUATE i.e. control comes out of the E
VALUATE as soon
as one match is
made.
Q19) What are the different forms of EVALUATE statement?
A19)
EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS
WHEN A=B AND C=D WHEN 100 ALSO '00'
imperative stmt imperative stmt
Page 5 of 260
IBMMAINFRAMES.com
WHEN (D+X)/Y = 4 WHEN -305 ALSO '32'
imperative stmt imperative stmt
WHEN OTHER WHEN OTHER
imperative stmt imperative stmt
END-EVALUATE END-EVALUATE
Q53) What compiler option would you use for dynamic linking?
Q53) DYNAM.
Q54) What is SSRANGE, NOSSRANGE ?
Q54) These are compiler options with respect to subscript out of range checking.
NOSSRANGE is the
default and if chosen,
no run time error will be flagged if your index or subscript goes out of the per
missible range.
Q55) How do you set a return code to the JCL from a COBOL program?
Q55) Move a value to RETURN-CODE register. RETURN-CODE should not be declared in
your
program.
Q56) How can you submit a job from COBOL programs?
Q56) Write JCL cards to a dataset with //xxxxxxx SYSOUT= (A,INTRDR) where 'A' is
output class, and
dataset should be
opened for output in the program. Define a 80 byte record layout for the file.
Q57) What are the differences between OS VS COBOL and VS COBOL II?
Page 9 of 260 IBMMAINFRAMES.com
Q57) OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms c
an run either in 24
bit or 31 bit
addressing modes.
I. Report writer is supported only in OS/VS Cobol.
II. USAGE IS POINTER is supported only in VS COBOL II.
III. Reference modification e.g.: WS-VAR(1:2) is supported only in VS COBOL II.
IV. EVALUATE is supported only in VS COBOL II.
V. Scope terminators are supported only in VS COBOL II.
VI. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.
VII. Under CICS Calls between VS COBOL II programs are supported.
Q58) What are the steps you go through while creating a COBOL program executable
?
Q58) DB2 precompiler (if embedded SQL used), CICS translator (if CICS pgm), Cobo
l compiler, Link
editor. If DB2
program, create plan by binding the DBRMs.
Q59) Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
Q59)
In non-CICS environment, it is possible. In CICS, this is not possible.
Q60) What are the differences between COBOL and COBOL II?
A60) There are at least five differences:
COBOL II supports structured programming by using in line Performs and explicit
scope
terminators, It introduces
new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs
to be
loaded and
addressed above the 16-megabyte line It does not support many old features (READ
Y TRACE,
REPORT-WRITER,
ISAM, Etc.), and It offers enhanced CICS support.
Q61) What is an explicit scope terminator?
A61)
A scope terminator brackets its preceding verb, e.g. IF .. END-IF, so that all s
tatements between the
verb and its scope terminator are grouped together. Other common COBOL II verbs
are READ,
PERFORM, EVALUATE, SEARCH and STRING.
Q62) What is an in line PERFORM? When would you use it? Anything else to say abo
ut it?
A62)
The PERFORM and END-PERFORM statements bracket all COBOL II statements between t
hem.
The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs
work as long as there are no internal GO TOs, not even to an exit. The in line P
ERFORM for
readability should not exceed a page length -often it will reference other PERFO
RM paragraphs.
Q63) What is the difference between NEXT SENTENCE and CONTINUE?
A63)
NEXT SENTENCE gives control to the verb following the next period. CONTINUE give
s control
to the next verb after the explicit scope terminator. (This is not one of COBOL
II's finer
implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL
II.
Q64) What COBOL construct is the COBOL II EVALUATE meant to replace?
A64)
EVALUATE can be used in place of the nested IF THEN ELSE statements.
Q65) What is the significance of 'above the line' and 'below the line'?
A65)
Before IBM introduced MVS/XA architecture in the 1980's a program's virtual stor
age was limited to
16 megs. Programs compiled with a 24 bit mode can only address 16 Mb of space, a
s though they
were kept under an imaginary storage line. With COBOL II a program compiled with
a 31 bit mode
can be 'above the 16 Mb line. (This 'below the line', 'above the line' imagery c
onfuses most
mainframe programmers, who tend to be a literal minded group.)
Page 10 of 260
IBMMAINFRAMES.com
Q66) What was removed from COBOL in the COBOL II implementation?
A66)
Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY,
STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.
Q67) Explain call by context by comparing it to other calls.
A67)
The parameters passed in a call by context are protected from modification by th
e called program. In
a normal call they are able to be modified.
Q68) What is the linkage section?
A68)
The linkage section is part of a called program that 'links' or maps to data ite
ms in the calling
program's working storage. It is the part of the called program where these shar
e items are defined.
Q69) What is the difference between a subscript and an index in a table definiti
on?
A69)
A subscript is a working storage data definition item, typically a PIC (999) whe
re a value must be
moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT
FROM
statements. An index is a register item that exists outside the program's workin
g storage. You SET
an index to a value and SET it UP BY value and DOWN BY value.
Q70) If you were passing a table via linkage, which is preferable -a subscript o
r an index?
A70)
Wake up -you haven't been paying attention! It's not possible to pass an index v
ia linkage. The
index is not part of the calling programs working storage. Those of us who've ma
de this mistake,
appreciate the lesson more than others.
Q71) Explain the difference between an internal and an external sort, the pros a
nd cons, internal
sort syntax etc.
A71)
An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is u
nderstandable
without any code reference. An internal sort can use two different syntax s: 1.) U
SING, GIVING
sorts are comparable to external sorts with no extra file processing; 2) INPUT P
ROCEDURE,
OUTPUT PROCEDURE sorts allow for data manipulation before and/or after the sort.
Q72) What is the difference between comp and comp-3 usage? Explain other COBOL u
sage s.
A72)
Comp is a binary usage, while comp-3 indicates packed decimal. The other common
usage s are
binary and display. Display is the default.
Q73) When is a scope terminator mandatory?
A73)
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. Fo
r
readability, it's recommended coding practice to always make scope terminators e
xplicit.
Q74) In a COBOL II PERFORM statement, when is the conditional tested, before or
after the
perform execution?
A74)
In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added
to
all perform statements. By default the test is performed before the perform.
Q75) In an EVALUTE statement is the order of the WHEN clauses significant?
A75)
Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their
sequence can
determine results.
Q76) What is the default value(s) for an INITIALIZE and what keyword allows for
an override of
the default.
A76)
INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. T
he REPLACING
option can be used to override these defaults.
Q77) What is SET TO TRUE all about, anyway?
Page 11 of 260
IBMMAINFRAMES.com
A77)
In COBOL II the 88 levels can be set rather than moving their associated values
to the related data
item. (Web note: This change is not one of COBOL II's better specifications.)
Q78) What is LENGTH in COBOL II?
A78)
LENGTH acts like a special register to tell the length of a group or elementary
item.
Q79) What is the difference between a binary search and a sequential search? Wha
t are the
pertinent COBOL
commands?
A79)
In a binary search the table element key values must be in ascending or descendi
ng sequence. The
table is 'halved' to search for equal to, greater than or less than conditions u
ntil the element is found.
In a sequential search the table is searched from top to bottom, so (ironically)
the elements do not
have to be in a specific sequence. The binary search is much faster for larger t
ables, while sequential
works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for
sequential.
Q80) What is the point of the REPLACING option of a copy statement?
A80)
REPLACING allows for the same copy to be used more than once in the same code by
changing the
replace value.
Q81) What will happen if you code GO BACK instead of STOP RUN in a stand alone C
OBOL
program i.e. a
program which is not calling any other program.
A81)
The program will go in an infinite loop.
Q82) How can I tell if a module is being called DYNAMICALLY or STATICALLY?
A82)
The ONLY way is to look at the output of the linkage editor (IEWL)or the load mo
dule itself. If the
module is being called DYNAMICALLY then it will not exist in the main module, if
it is being
called STATICALLY then it will be seen in the load module. Calling a working sto
rage variable,
containing a program name, does not make a DYNAMIC call. This type of calling is
known as
IMPLICITE calling as the name of the module is implied by the contents of the wo
rking storage
variable. Calling a program name literal (CALL
Q83) What is the difference between a DYNAMIC and STATIC call in COBOL.
A83)
To correct an earlier answer: All called modules cannot run standalone if they r
equire program
variables passed to them via the LINKAGE section. DYNAMICally called modules are
those that are
not bound with the calling program at link edit time (IEWL for IBM) and so are l
oaded from the
program library (joblib or steplib) associated with the job. For DYNAMIC calling
of a module the
DYNAM compiler option must be chosen, else the linkage editor will not generate
an executable as
it will expect u address resolution of all called modules. A STATICally called m
odule is one that is
bound with the calling module at link edit, and therefore becomes part of the ex
ecutable load module.
Q84) How may divisions are there in JCL-COBOL?
A84)
SIX
Q85) What is the purpose of Identification Division?
A85)
Documentation.
Q86) What is the difference between PIC 9.99 and 9v99?
A86)
PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where a
s PIC 9v99 is
THREE-POSITION numeric field with implied or assumed decimal position.
Q87)
what is Pic 9v99 Indicates?
A87)
PICTURE 9v99 is a three position Numeric field with an implied or assumed decima
l point after the
first position; the v means an implied decimal point.
Page 12 of 260
IBMMAINFRAMES.com
Q88) What guidelines should be followed to write a structured Cobol prg'm?
A88)
1) use 'evaluate' stmt for constructing cases.
2) use scope terminators for nesting.
3) use in line perform stmt for writing 'do ' constructions.
4) use test before and test after in the perform stmt for writing do-while const
ructions.
Q89) Read the following code. 01 ws-n pic 9(2) value zero. a-para move 5 to ws-n
. perform b-para
ws-n times. b-para.
move 10 to ws-n. how many times will b-para be executed ?
A89)
5 times only. it will not take the value 10 that is initialized in the loop.
Q90) What is the difference between SEARCH and SEARCH ALL? What is more efficien
t?
A90)
SEARCH is a sequential search from the beginning of the table. SEARCH ALL is a b
inary search,
continually dividing the table in two halves until a match is found. SEARCH ALL
is more efficient
for tables larger than 70 items.
Q91) What are some examples of command terminators?
A91)
END-IF, END-EVALUATE
Q92) What care has to be taken to force program to execute above 16 Meg line?
A92)
Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should neve
r have
SIZE(MAX). BUFSIZE can be 2K, efficient enough.
Q93) How do you submit JCL via a Cobol program?
A93)
Use a file //dd1 DD sysout=(*, intrdr)write your JCL to this file. Pl some on tr
y this out.
Q94) How to execute a set of JCL statements from a COBOL program
A94)
Using EXEC CICS SPOOL WRITE(var-name) END-EXEC command. var-name is a COBOL host
structure containing JCL statements.
Q95) Give some advantages of REDEFINES clause.
A95)
1.
You can REDEFINE a Variable from one PICTURE class to another PICTURE class by u
sing
the same memory
location.
2.
By REDEFINES we can INITIALISE the variable in WORKING-STORAGE Section itself.
3.
We can REDEFINE a Single Variable into so many sub variables. (This facility is
very useful in
solving Y2000
Problem.)
Q96) What is the difference between static call & Dynamic call
A96)
In the case of Static call, the called program is a stand-alone program, it is a
n executable program.
During run time we can call it in our called program. As about Dynamic call, the
called program is
not an executable program it can executed through the called program
Q97) What do you feel makes a good program?
A97)
A program that follows a top down approach. It is also one that other programmer
s or users can
follow logically and is easy to read and understand.
Q98) How do you code Cobol to access a parameter that has been defined in JCL? A
nd do you code
the PARM
parameter on the EXEC line in JCL?
A98)
1)
using JCL with sysin. //sysin dd *here u code the parameters(value) to pass in t
o cobol program
/* and in program
Page 13 of 260
IBMMAINFRAMES.com
Q100) The maximum number of dimensions that an array can have in COBOL-85 is ---
--------?
A100) SEVEN in COBOL -85 and THREE in COBOL -84
Q101) How do you declare a host variable (in COBOL) for an attribute named Emp-N
ame of type
you use accept variable name(one accept will read one row)/.another way.
2)
in jcl using parm statement ex: in exec statement parm='john','david' in cobol p
gm u have to code
linkage section in that for first value you code length variable and variable na
me say, abc pic
x(4).it will take john inside to read next value u have to code another variable
in the same way
above mentioned.
Q99) Why do we code S9(4) comp. Inspite of knowing comp-3 will occupy less space
.
A99)
Here s9(4)comp is small integer ,so two words equal to 1 byte so totally it will
occupy 2 bytes(4
words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2
bytes and sign will
occupy 1/2 byte so totally it will occupy 3 bytes.
VARCHAR(25) ?
A101)
01 EMP-GRP.
49 E-LEN PIC S9(4) COMP.
49 E-NAME PIC X(25).
Q102)
What is Comm?
A102)
COMM -HALF WORD BINARY
Q103) Differentiate COBOL and COBOL-II. (Most of our programs are written in COB
OLII, so,
it is good to know,
how, this is different from COBOL)
A103)
The following features are available with VS COBOL II:
1. MVS/XA and MVS/ESA support The compiler and the object programs it produces c
an be
run in either
24-or 31-bit addressing mode.
2. VM/XA and VM/ESA support The compiler and the object programs it produces can
be run
in either
24-or 31-bit addressing mode.
3. VSE/ESA support The compiler and the object programs it produces can be run u
nder
VSE/ESA.
Q104)
What is PERFORM ? What is VARYING ? (More details about these clauses)
A104)
The PERFORM statement is a PROCEDURE DIVISION statement which transfers control
to
one or more specified procedures and controls as specified the number of times t
he procedures are
executed. After execution of the specified procedures is completed (i.e., for th
e appropriate
number of times or until some specified condition is met), control is transferre
d to the next
executable statement following the PERFORM statement. There are 5 types of PERFO
RM
statements:
a) Basic PERFORM
b) PERFORM TIMES
c) PERFORM UNTIL
d) PERFORM VARYING
e) IN-LINE PERFORM
Q105)
How many sections are there in data division?.
A105)
SIX SECTIONS 1.FILE SECTION 2.WORKING-STORAGE SECTION 3. LOCAL-STORAGE
SECTION 4.SCREEN SECTION 5.REPORT SECTION 6. LINKAGE SECTION
Page 14 of 260
IBMMAINFRAMES.com
Q106)
What is Redefines clause?
A106) Redefines clause is used to allow the same storage allocation to be refere
nced by different data
names .
Q107)
A107)
How many bytes does a s9(4)comp-3 field occupy?
3Bytes (formula : n/2 + 1))
Q108)
A108)
What is the different between index and subscript?
Subscript refers to the array of occurrence , where as Index represents an occur
rence of a table
element. An index can only modified using perform, search & set. Need to have an
index for a
table in order to use SEARCH and SEARCH All.
Q109) What is the difference between Structured COBOL Programming and Object Ori
ented
COBOL
programming?
A109)
Structured programming is a Logical way of programming, you divide the functiona
lities into
modules and code logically. OOP is a Natural way of programming; you identify th
e objects first,
and then write functions, procedures around the objects. Sorry, this may not be
an adequate
answer, but they are two different programming paradigms, which is difficult to
put in a sentence
or two.
Q110)
What divisions, sections and paragraphs are mandatory for a COBOL program?
A110) IDENTIFICATION DIVISION and PROGRAM-ID paragraph are mandatory for a compi
lation
error free COBOL
program.
Q111)
Can JUSTIFIED be used for all the data types?
A111)
No, it can be used only with alphabetic and alphanumeric data types.
Q112)
What happens when we move a comp-3 field to an edited (say z (9). ZZ-)
A112)
the editing characters r to be used with data items with usage clause as display
which is the
default. When u tries displaying a data item with usage as computational it does
not give the
desired display format because the data item is stored as packed decimal. So if
u want this
particular data item to be edited u have to move it into a data item whose usage
is display and then
have that particular data item edited in the format desired.
Q113)
What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL
program i.e. a program which is not calling any other program ?
A113)
Both give the same results when a program is not calling any other program. GO B
ACK will give
the control to the system even though it is a single program.
Q114)
what is the difference between external and global variables?
A114)
Global variables are accessible only to the batch program whereas external varia
bles can be
referenced from any batch program residing in the same system library.
Q115)
You are writing report program with 4 levels of totals: city, state, region and
country. The
codes being used can be the same over the different levels, meaning a city code
of 01 can be
in any number of states, and the same applies to state and region code so how do
you do your
checking for breaks and how do you do add to each level?
A115)
Always compare on the highest-level first, because if you have a break at a high
est level, each level
beneath it must also break. Add to the lowest level for each record but add to t
he higher level only
on a break.
Q116)
What is difference between COBOL and VS COBOL II?.
Page 15 of 260
IBMMAINFRAMES.com
A116)
In using COBOL on PC we have only flat files and the programs can access only li
mited storage,
whereas in VS COBOL II on M/F the programs can access up to 16MB or 2GB dependin
g on the
addressing and can use VSAM
files to make I/O operations faster.
Q117)
Why occurs can not be used in 01 level ?
A117)
Because, Occurs clause is there to repeat fields with same format, not the recor
ds.
Q118)
What is report-item?
A118)
A Report-Item Is A Field To Be Printed That Contains Edit Symbols
Q119)
Difference between next and continue clause
A119)
The difference between the next and continue verb is that in the continue verb i
t is used for a
situation where there in no EOF condition that is the records are to be accessed
again and again in
an file, whereas in the next verb the indexed file is accessed sequentially, rea
d next record
command is used.
Q120)
What is the Importance of GLOBAL clause According to new standards of COBOL
A120)
When any data name, file-name, Record-name, condition name or Index defined in a
n Including
Program can be referenced by a directly or indirectly in an included program, Pr
ovided the said
name has been declared to be a global name by GLOBAL Format of Global Clause is0
1 data-1 pic
9(5) IS GLOBAL.
Q121)
What is the Purpose of POINTER Phrase in STRING command
A121)
The Purpose of POINTER phrase is to specify the leftmost position within receivi
ng field where
the first transferred character will be stored
Q122)
How do we get current date from system with century?
A122)
By using Intrinsic function, FUNCTION CURRENT-DATE
Q123)
What is the maximum length of a field you can define using COMP-3?
A123)
10 Bytes (S9(18) COMP-3).
Q124)
Why do we code s9 (4) comp? In spite of knowing comp-3 will occupy less space?
A124)
Here s9(4)comp is small integer, so two words equal to 1 byte so totally it will
occupy 2 bytes(4
words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2
bytes and sign will
occupy 1/2 byte so totally it will occupy 3 bytes.
Q125)
What is the LINKAGE SECTION used for?
A125)
The linkage section is used to pass data from one program to another program or
to pass data from
a PROC to a program.
Q126)
Describe the difference between subscripting and indexing ?
A126)
Indexing uses binary displacement. Subscripts use the value of the occurrence.
1. What R 2 of the common forms of the EVALUATE STATEMENT ?
2. What does the initialize statement do ?
3. What is the reference modification.
4. Name some of the examples of COBOl 11?
5. What are VS COBOL 11 special features?
6. What are options have been removed in COBOL 11?
7. What is the file organization clause ?
8. What is a subscript ?
9. What is an index for tables?
10. What are the two search techniques ?
Page 16 of 260
IBMMAINFRAMES.com
11. What is an in-line perform ?
12. What is CALL statement in COBOL?
13. When can the USING phrase be included in the call statement ?
14. In EBCDIC, how would the number 1234 be stored?
15. How would the number +1234 be stored if a PIC clause of PICTUREs9(4) comp-3
were used?
16. What is Alternate Index ? How is it different from regular index ?
Page 17 of 260 IBMMAINFRAMES.com
Customer Information Control System(CICS)
IBM s Customer Information Control System (CICS) is an on-line teleprocessing syst
em developed by
IBM. By providing a sophisticated control and service database/data communicatio
n system, the application
developer can concentrate on fulfilling specific business needs rather than on c
ommunication and internal
system details. CICS allows data to be transmitted from the terminal to the host
computer, have the data
processed, access files/databases, and then have data to be transmitted from the
terminal to the host
computer, have the data processed, access files/databases, and then have data tr
ansmitted back to the
terminal. To accomplish that, CICS uses a telecommunication package such as VTAM
or TCAM and
various file access methods: VSAM, DL/1, DB2, etc.
The latest release CICS/ESA is Release 3.3.
Some of the new functionality includes:
1.
Expanded features for the system programmer
2.
Improved above the line storage utilization
3.
New options for many CICS commands
4. Improved cross-platform communication facilities
Functionality
CICS provides the following support:
Data Communications
An interface between the terminal and printers with CICS via a telecommunication
access method
(TCAM or VTAM).
Multi Region Operation(MRO), through which more than one CICS region of a system
can
communicate
Intersystem Communication (ISC), through which one CICS region of a system can c
ommunicate
with other CICS regions in other systems
Application Programming
An interface with database access methods such as DB2, DL/1, and VSAM
An interface with error checking and reporting facilities
Terminology:
CICS has its own language. Some of the language abbreviations of CICS are:
Page 18 of 260
IBMMAINFRAMES.com
SIT System Initialization Table
PCT Program Control Table
PPT Program Processing Table
TCT Terminal Control Table
FCT File Control Table
TCP Terminal Control Program
TCTUA Terminal Control Terminal User Area
DCT Destination Control Table
TDQ Transient Data Queue
EIP Execution Interface Program
FCP File Control Program
ICP Interval Control Program
KCT Task Control Program
PCP Program Control Program
SCP Storage Control Program
TCA Task Control Area
TCTTE Terminal Control Table Terminal Entry
TSQ Temporary Storage Queue
TWA Task Work Area
AID Attention Identifier
CWA Common Work Area
MRO Multi Region Operation
QID Queue Identifier
Q1) What are the six different types of argument values in COBOL that can be pla
ced in various
options of a CICS command?
A1)
·Data Value -EX (Literal 8 or 77 KEYLEN PIC S9(4) COMP VALUE 8.)
·Data Area -EX (01 RECORD-AREA.
05 FIELD1 PIC X(5). )
·Pointer-Ref -EX (05 POINTER-I PIC S9(8) COMP. )
·Name -EX (05 FILE-NAME PIC X(5) VALUE FILEA . )
·Label -Cobol paragraph name
·HHMMSS -EX (77 TIMEVAL PIC S9(7) COMP3. )
Q2) Kindly specify the PIC clause for the following
Any BLL Cell, Data type of Length Option field, HHMMSS type of data fields
A2) Any BLL Cell -S9(8) COMP
Data type of Length Option field -S9(4) COMP
HHMMSS type of data fields -S9(7) COMP3
Q3) Specify CICS transaction initiation process. (From the perspective of CICS c
ontrol programs
and control tables.)
A3) TCP places data in TIOA and corresponding entry into TCT.
KCP acquires the transaction identifier from TIOA and verifies if it is present
in PCT.
SCP acquires Storage in Task Control Area (TCA), in which KCP prepares control d
ata for the task.
KCP then loads the application programs mentioned in PCT by looking for it in PP
T.
If resident -real storage memory location is not present in the PPT the control
is passed to PCP that
loads the application programs from the physical storage location address given
in PPT. The control is
then passed to the application program (LOAD module).
Q4) List the sequence of steps used to achieve Modification in Skip Sequential Mo
de.
A4)
Page 19 of 260 IBMMAINFRAMES.com
I. READNEXT command
II. Issue the ENDBR command
III. Issue the READ command with UDTAE option.
IV. Manipulate the record (DELETE or REWRITE command)
V. Issue START command
VI. Issue two READNEXT commands (One for dummy skip)
VII. Go to step two.
Q5) Specify the requirements for Automatic Task Initiation. (Mention the control
table, it s entries
and the corresponding Procedure division CICS command).
A5) DFHDCT
TYPE=INTRA,
DESTID=MSGS,
TRANSID=MSW1,
TRIGLEV=1000
EXEC CICS WRITEQ TD
QUEUE( MSGS ),
FROM(DATA-AREA),
LENGTH(MSG_LEN)
END-EXEC.
Q6) What are the commands used to gain exclusive control over a resource (for Ex
a Temporary
storage queue.)?
A6) EXEC CICS ENQ EXEC CICS DEQ
RESOURCE(QID) RESOURCE(QID)
END-EXEC END-EXEC
Q7) What is the EIB parameter and the CICS command used to implement Pseudo-Conv
ersational
technique using single PCT -Single PPT entry?
A7) EIBCALEN -To check if COMMAREA has been passed in terurn command.
EXEC CICS RETURN
TRANSID(data-name)
COMMAREA(data-area)
LENGTH(data-value)
END-EXEC
Q8) Mention the 5 fields available in the symbolic map for every NAMED field in th
e DFHMDI
macro? Give a brief description of these fields (Not exceeding a line).
A8) FIELD+L -Return the length of text entered (or for dymanic cursor positioing
)
FIELD+F -Returns X(80) if data entered but erased.
FIELD+A -Used for attributes reading and setting
FIELD+I -Used for reading the text entered while receiving the map.
FIELD+O -Used for sending information on to the MAP.
Q9) What are the two ways of breaking a CPU bound process to allow other tasks t
o gain access to
CPU.
A9) EXEC CICS DELAY EXEC CICS DELAY
INTERVAL(hhmmss) TIME(hhmmss)
END-EXEC END-EXEC
POST and WAIT commands also achieve the same result.
Q10) How do you initiate another transaction? The transaction initiated should b
e in a position to
retrieve
Page 20 of 260
IBMMAINFRAMES.com
information pertaining to which transaction has initiated it and from which term
inal. (Code
the required CICS
commands)
A10) EXEC CICS START
INTERVAL(hhmmss)/TIME(hhmmss)
TRANSID( TRAN )
TERMID( TRM1)
FROM(data-area)
LENGTH(data-value)
RTRANSID(EIBTRNID)
RTERMID(EIBTRMID)
END-EXEC
EXEC CICS RETRIEVE
INTO(data-area)
LENGTH(data-value)
RTRANSID(data-name)
RTERMID(data-name)
END-EXEC
Q11) Mention the option (along with argument type) used in a CICS command to ret
rieve the
response code after
execution of the command.
A11) RESP( S9(8) COM.)
Q12) What s the CICS command used to access current date and time?
A12) ASKTIME.
Q13) Into what fields will the date and time values be moved after execution of
the above command?
A13) EIBDATE & EIBTIME.
Q14) How do you terminate an already issued DELAY command?
A14) EXEC CICS CANCEL
REQID(id)
END-EXEC
Q15) How do you dynamically set the CURSOR position to a specific field?
A15) MOVE -1 to FIELD+L field. Mention CURSOR option in the SEND command.
Q16) Which option of the PCT entry is used to specify the PF key to be pressed f
or initiating a
transaction?
A16) TASKREQ=PF1
Q17) Specify the CICS command used to read a VSAM record starting with prefix F . C
ode all the
relevant options.
A17) EXEC CICS READ
DATASET( FILENAME )
INTO(data-area)
RIDFLD(data-area)
KEYLENGTH(1)
GENERIC
LENGTH(WK-LEN)
END-EXEC.
Page 21 of 260 IBMMAINFRAMES.com
Q18) Mention the option used in the CICS READ command to gain accessibility dire
ctly to the file
I/O area. (Assume
COBOL-II).
A18) SET(ADDRESS OF LINKAGE-AREA).
Q19) Which command is used to release a record on which exclusive control is gai
ned?
A19) EXEC CICS UNLOCK END-EXEC.
Q20) How do you establish a starting position in a browse operation?
A20) EXEC CICS STARTBR----------END-EXEC.
Q21) What is the option specified in the read operation to gain multiple concurr
ent operations on
the same dataset?
A21) REQID(value).
Q22) What is the CICS command that gives the length of TWA area?
A22) EXEC CICS ASSIGN
TWALENG(data-value)
END-EXEC.
Q23) What are the attribute values of Skipper and Stopper fields?
A23) ASKIP, PROT.
Q24) How do you set the MDT option to ON status, even if data is not entered?
A24) Mention FSET option in DFHMDF or set it dynamically in the program using FI
ELD+A attribute
field.
Q25) What option is specified in the SEND command to send only the unnamed field
s on to the
screen?
A25) MAPONLY_______________.
Q26) Which CICS service transaction is used to gain accessibility to CICS contro
l tables? Mention
the one that has
the highest priority.
A26) CEDA
Q27) What is the most common way of building queue-id of a TSQ? (Name the consti
tuents of the
Queue ID).
A27) TERMID+TRANSACTION-ID.
Q28) Into which table is the terminal id registered?
A28) TCT.
Q29) How and where is the TWA size set? .
A29) TWASIZE=300 in PCT table.
Q30) Which transient data queue supports ATI?
A30) INTRA-PARTITION Data queue.
Q31) Code the related portions of CICS/COBOL-I programs to gain addressability t
o TWA area
assigned to a
particular task. Assume that the size of TWA area is 300 bytes. What are the adv
antages if
COBOL-II is used
in the place of COBOL? Code the above requirement in COBOL-II.
Page 22 of 260 IBMMAINFRAMES.com
A31)
COBOL-II PROGRAM
LINKAGE SECTION.
01 PARMLIST.
02 FILLER PIC S9(8) COMP.
02 TWA-PTR S(98) COMP.
01 TWA-DATA-LAYOUT.
02 DATA-AREA PIC X(300).
PROCEDURE DIVISION.
.
EXEC CICS ADDRESS
TWA(TWA-PTR)
END-EXEC
SERVISE RELOAD TWA-DATA-LAYOUT.
COBOL-II PROGRAM
LINKAGE SECTION.
01 TWA-DATA-LAYOUT.
05 DATA-AREA PIC X(300).
PROCEDURE DIVISION.
.
EXEC CICS ADDRESS
TWA(ADDRESS OF TWA-DATA-LAYOUT)
END-EXEC
STATUS :
EXIT : X
X -Input Field
Page 23 of 260 IBMMAINFRAMES.com
Mapname -EMPFORM
Mapsetname -EMPFORM
Label given to various named fields on the DFHMDF macro while defining the map sho
wn above. EMPID,
EMPNAME, EMPDESIG, DEPART, SEX, SALARY, STATUS and EXITINP.
Structure of the VSAM/KSDS file.
Working-Storage Section.
01 EMP-IOAREA.
05 EMP-REC.
10 EMP-KEY PIC XXX.
10 EMP-NAME PIC X(32).
10 EMP-SEX PIC X.
10 EMP-DEPT PIC X(10)
10 EMP-DESIG PIC X(5).
10 EMP-SAL PIC 9(7).
01 STATUS.
02 NORMAL.
05 FILLER PIC X(8) VALUE EMP ID: .
05 EMP-ID PIC X(3).
05 FILLER PIC X(6) VALUE FOUND .
01 EMP-IOAREA.
05 EMP-REC.
10 EMP-KEY PIC XXX.
10 EMP-NAME PIC X(32).
10 EMP-SEX PIC X.
10 EMP-DEPT PIC X(10)
10 EMP-DESIG PIC X(5).
10 EMP-SAL PIC 9(7).
LINKAGE SECTION.
01 DFHCOMMAREA.
05 INPVAL PIC X(3).
PROCEDURE DIVISION.
..
IF EIBCALEN=0
END-EXEC.
Page 24 of 260 IBMMAINFRAMES.com
MOVE 3 TO LENGTH-OF-AREA
EXEC CICS RETURN
TRANSID( EMPS )
COMMAREA( SEC )
LENGTH(DATA-VALUE)
END-EXEC.
ELSE IFINPVAL = SEC
EXEC CICS RECEIVE
MAP( EMPFORM )
MAPSET( EMPFORM )
END-EXEC.
EXEC CICS READ
DATASET( EMPINFOR )
INTO(EMP-IOAREA)
RIDFLD(EMPIDI)
LENGTH(LENGTH-OF-AREA)
RESP(WS-RCODE)
END-EXEC.
IF WS-RCODE NOT = DFHRESP(NORMAL)
MOVE KEY NOT FOUND TO ABMSG
MOVE DFHBMBRY TO EMPIDA
ELSE
MOVE EMP-NAME TO EMPNAMEO
MOVE EMP-SEX TO SEXO
MOVE EMP-DESIG TO EMPDESIGO
MOVE EMP-SAL TO SALARY
MOVE EMP-DEPT TO DEPARTO
MOVE EMP-KEY TO EMP-ID
MOVE STATUS TO STATUSO.
EXEC CICS SEND
MAP( EMPFORM )
MAPSET( EMPFORM )
ERASE
END-EXEC.
MOVE 3 TO LENGTH-OF-AREA
EXEC CICS RETURN
TRANSID( EMPS )
COMMAREA( SEC )
LENGTH(LENGTH-OF-AREA)
END-EXEC.
EXEC CICS RETURN
END-EXEC.
ELSE IF (EXITINPI NOT = Y )
EXEC CICS RETURN
END-EXEC.
Page 25 of 260 IBMMAINFRAMES.com
Q33) What does Pseudo Conversational mean?
A33) The programming technique in which the task will not wait for the end-user
replies on the terminal.
Terminating the
task every time the application needs a response from the user and specifying th
e next transaction to
be started when
the end user press any attention key (Enter, PF1 through PF24, PA1,PA2 and Clear
) is pseudo-
conversational
processing.
Q34) Explain the means of supporting pseudo conversation programming. (E.g. Stor
ing and
restoring of states,
control flow, error handling)
A34) When we send a map using SEND MAP command. Immediately we release the progr
am by
using EXEC
CICS RETURN command. In this command we mention the TRANSACTION ID which is to
be executed
after receiving the map. In this command we also specify the data that should be
stored in
COMMUNICATION AREA for later use. When this command is executed the correspondin
g
program is
released from the memory. After receiving the response from the terminal the pro
gram is again
loaded and this
time the data which we stored in communication area will be copied into the work
ing storage
section. And
the map will be received with RECEIVE MAP command.
The variable EIBCALEN in EIB holds the length of communication area. In procedur
e
division we checks the value of EIBCALEN If it is zero, we first send the map fo
llowed by
RETURN command. Otherwise, that is if EIBCALEN is not zero, we know that this tr
ansaction
is not running first time and we receive the map by using RECEIVE MAP command.
Q35) What is the function of the CICS translator?
A35)
The CICS translator converts the EXEC CICS commands into call statements for a s
pecific
programming language. There are CICS translators for Assembler, COBOL, and PL/1.
Q36) How can you start a CICS transaction other than by keying the Transaction I
D at the
terminal?
A36)
By coding an EXEC CICS START in the application program
1. By coding the trans id and a trigger level on the DCT table
2. By coding the trans id in the EXEC CICS RETURN command
3. By associating an attention key with the Program Control Table
4. By embedding the TRANSID in the first four positions of a screen sent to the
terminal.
5. By using the Program List Table
Q37) What is the purpose of the Program List Table?
A37) The Program List Table records the set of applications programs that will b
e executed automatically
at CICS start-up
time.
Q38) What are the differences between and EXEC CICS XCTL and an EXEC CICS START
command?
A38)
The XCTL command transfer control to another application (having the same Transa
ction ID), while
the START command initiates a new transaction ID (therefore a new task number).
The XCTL
continues task on the same terminal. START can initiate a task on another termin
al.
Page 26 of 260
IBMMAINFRAMES.com
Q39) What are the differences between an EXEC CICS XCTL and an EXEC CICS LINK
command.
A39)
The XCTL command transfer control to an application program at the same logical
level (do not
expect to control back), while the LINK command passes control to an application
program at the
next logical level and expects control back.
Q40) What happens to resources supplied to a transaction when an XCTL command is
executed?
A40)
With an XCTL, the working storage and the procedure division of the program issu
ing the XCTL are
released. The I/O areas, the GETMAIN areas, and the chained Linkage Section area
s (Commarea
from a higher level) remain. All existing locks and queues also remain in effect
. With a LINK,
however, program storage is also saved, since the transaction expects to return
and use it again.
Q41) What CICS command do you need to obtain the user logon-id?
A41)
You must code EXEC CICS ASSIGN with the OPERID option.
Q42) What is a resident program?
A42)
A program or map loaded into the CICS nucleus so that it is kept permanently in
main storage and
not deleted when CICS goes Short On Storage .
Q43) What is EIB. How it can be used?
A43)
CICS automatically provides some system-related information to each task in a fo
rm of EXEC
Interface Block (EIB), which is unique to the CICS command level. We can use all
the fields of
EIB in our application programs right away.
Q44) What is some of the information available in the EIB area?
A44)
I. The cursor position in the map
II. Transaction ID
III. Terminal ID
IV. Task Number
V. Length of communication area
VI. Current date and time
VII. Attention identifier
Q45) What information can be obtained from the EIBRCODE?
A45)
The EIBRCODE tells the application program if the last CICS command was executed
successfully
and, if not, why not.
Q46) What is the effect of including the TRANSID in the EXEC CICS RETURN command
?
A46)
The next time the end user presses an attention key, CICS will start the transac
tion specified in the
TRANSID option.
Q47) Explain how to handle exceptional conditions in CICS.
A47) An abnormal situation during execution of a CICS command is called an excep
tional
condition".
There are various ways to handle these exception conditions:
1. Handle Condition Command: It is used to transfer control to the procedure lab
el specified if
the
exceptional condition specified occurs.
Q64) Name three ways the Modified Data Tag can be set on?
A64)
The Modified Data Tag can be set on:
1. When the user enters data into the field.
2. When the application program moves DFHBMFSE to the attribute character.
3. By defining it in the BMS macro definition.
Q65) What is a mapset?
A65)
A mapset is a collection of BMS maps link-edited together.
Q66) What is the function of DFHMDF BMS macro?
A66)
The DFHMDF macro defines fields, literal, and characteristics of a field.
Q67) Why is a TERM ID recommended in naming a TSQ?
A67)
In order to avoid confusion and to maintain data security, a strict naming conve
ntion
for QID will be required in the installation. Moreover, for a terminal-dependent
task (e.g.,
pseudo-conversational task), the terminal id should be included in QID in order
to
ensure the uniqueness of TSQ to the task.
Q68) Explain the basic difference between Intra partition TDQ and Extra partitio
n TDQ.
A68)
INTRA PARTITION TD QUEUEs It is a group of sequential records which are produced
by the same
and / or different transactions within a CICS region. These Qs are stored in onl
y one physical
file ( VSAM ) in a CICS region, which is prepared by the system programmer. Once
a record
is read from a queue, the record will be logically removed from the queue; that
is the record
cannot be read again. EXTRA PARTITION TD QUEUEs It is a
group of sequential records which interfaces between the transactions of the CIC
S region
and the systems outside of CICS region. Each of these TDQs is a separate physica
l file, and it
may be on the disk, tape, printer or plotter.
Q69) What are the differences between Temporary Storage Queue (TSQ) and Transien
t Data Queue
(TDQ).?
A69)
Temporary Storage Queue names are dynamically defined in the application program
, while TDQs
must first be defined in the DCT (Destination Control Table). When a TDQ contain
s certain amount
of records (Trigger level), a CICS transaction can be started automatically. Thi
s does not happen
when using a TSQ. TDQ(extra partition) may be used by batch application; TSQ can
not be accessed
in batch. The Transient Data Queue is actually a QSAM file. You may update an ex
isting item in a
TSQ. A record in a TDQ cannot be updated. Records in TSQ can be read randomly. T
he TDQ can be
read only sequentially. Records in Temporary Storage can be read more than once,
while records
stored in Temporary Data Queues cannot. With TDQs it is one read only.
Page 31 of 260
IBMMAINFRAMES.com
Q70) What is the difference between getting the system time with EIBTIME and ASK
TIME
command?
A70)
The ASKTIME command is used to request the current date and time. Whereas, the
EIBTIME field have the value at the task initiation time.
Q71) What does the following transactions do?
A71) CEDF : CICS-supplied Execution Diagnostic Facility transaction. It provides
interactive
program
execution and debugging functions of a CICS programs.
CEMT : CICS-supplied Extended Master Terminal transaction. It displays or manipu
lates
CICS
control environment interactively.
CEBR : CICS-supplied Temporary Storage Browse transaction. It displays the conte
nt of
Temporary Storage Queue ( TSQ ).
CECI : CICS-supplied Command Interpreter transaction. It verifies the syntax of
a CICS
command
and executes the command.
Q72) Explain floating maps with illustration.
A72)
Maps which can position themselves relative to the previous maps on the screen o
r page are known
as
the floating maps. For this you have to use special positional operands to LINE
and COLUMN
parameters of the BMS macro definition. They are SAME, NEXT. Actually this float
ing map
concept is there only in Full BMS where as it is not available in Min. or Standa
rd BMS macros.
RECEIVE MAP is not recommended in the case of floating maps. Hence these maps ar
e normally
used to send information such as selected records from a database to screen but
not for data entry. A
mapset can contain more than one m ap in it, you may use all these maps to build
a screen. In that
case there are two ways to send these maps on to the screen
i ) Use separate SEND MAP commands one for each map involved. or
ii) Use ACCUM operand along with SEND MAP command and while sending really on
to the
screen use SEND PAGE to display them at one shot. The second one is called
cumulative mapping scheme where you also can use floating maps.
Let's take a situation where you have to build a screen like this
HEADER MAP (no. of A gr. employs)
DETAIL MAP (employee list )
TRAILER MAP (Press a key to continue...)
Under such situations whatever the detail map needed that is to be displayed aga
in and again to
display all the information one screenful at a time. In this floating map concep
t helps.
Code the map like this
M1 DFHMDI ...... HEADER=YES,JUSTIFY=FIRST..................
M2 DFHMDI ... ......................... LINE=NEXT....................
M3 DFHMDI ........TRAILER=YES,JUSTIFY=LAST...........................
A109) The enter and PF keys transmit data from the screen; the PA keys tell CICS
that a terminal action
took place, but
data is not transmitted.
Q110) Explain the difference among the EXEC LINK, EXEC XCTL and Cobol II static
call
statements in CICS.
A110) COBOL II allows for static calls which are more efficient than the LINK in
struction which
establishes a new rununit.
operation.
FSET: Sets MDT on to ensure field is transmitted. Happens on an output operation
.
FRSET: Resets MDT. Until this happens, field continues to be sent.
Q305)
Which of the following statements correctly describe the syntax of CICS command
language?
A). If an EXEC CICS command must be continued onto a second line a hyphen (-) mu
st be
coded in column 7 of the continued line.
B). If an EXEC CICS command must be continued onto a second line an 'X' must be
coded
in column 72 of each line to be continued.
Page 50 of 260
IBMMAINFRAMES.com
A305)
Q306)
A306)
Q307)
A307)
Q308)
A308)
Q309)
A309)
Q310)
A310)
C). An EXEC CICS command CANNOT be coded within a COBOL IF statement, between
the IF command and the period (.) ending it.
D). The END-EXEC delimiter is optional and never needs to be placed at the end o
f a CICS
command.
E). The options specified within an EXEC CICS command can be in any order.
E. The options specified within an EXEC CICS command can be in any order. For ex
ample 'exec
CICS Send From(Msg1) Length(30) End-Exec' can also be coded 'exec Cics Send Leng
th(30)
From(Msg1) End-Exec'
A CICS program ABENDS with an ASRA ABEND code. What is its meaning?
A) A link was issued to a program whose name does not exist in the PPT (Program
Processing Table).
B) A program attempted to use a map that is not defined in the PCT (Program Cont
rol
Table).
C) A security violation has occurred. The operator is not defined with the prope
r authority in
the SNT (Sign
Q3) In what RDMS object does one first list column names?
A3) One first uses the column name in the CREATE TABLE statement.
Q4) What is the syntax for a CREATE TABLE statement?
A4) CREATE TABLE table name
(column name list
primary key (column name))
in database-name, tablespace-name.
Q5) Can one add columns to a table after it has been defined?
A5) Yes, one can add column to a table after it has been defined by using the SQ
L ALTER TABLE
statement.
Q6) Where in a table are added columns located?
A6) The new columns are added to the end of the table.
Q7) After a table is defined, can columns be removed?
A7) The only way to remove columns from an existing table involves a migration p
rogram that extracts only
the desired
columns of data, redefining the table without the unwanted columns, then populat
ing the new table.
One have to handle
all the old table s dependents programmatically.
Page 59 of 260 IBMMAINFRAMES.com
Q8) Which RDMS objects can you change with the SQL ALTER statements?
A8) The SQL ALTER statement can change a table index, a table, a tablespace, or
a STOGROUP.
Q9) What authority is required to create a table?
A9) In order to create tables, one needs CREATETAB privileges.
Q10) What is minimum authority required for one to create a tablespace?
A10) In order to create tablespaces, one needs CREATETS privileges.
Q11) When is it necessary to create a table index?
A11) It is necessary to create a table index whenever you want to enforce the un
iqueness of the table s
primary key.
Q12) What is a synonym?
A12) A synonym is an unqualified alternative name for a table or view.
Q13) What is a foreign key?
A13) A foreign key is the key defined in one table to reference the primary key
of a reference table. This
foreign key must
have the same structure as the reference table s primary key.
Q14) What is referential integrity?
A14) Referential integrity is the automatic enforcement of referential constrain
ts that exist between a
reference table and a
referencing table. When referential integrity is enforced, the value of a foreig
n key exists as a
primary key value in the
reference table. In other words, when referential integrity is enforced, all of
the foreign key values in,
for example, the
department code column in an employee table exist as primary key values in a departme
nt
table.
Q15) What are the column name qualifiers?
A15) A column name qualifier are used as a table designator to avoid ambiguity w
hen the column names
referenced exists
in more than one table used in the SQL statement. Column name qualifiers are als
o used in correlated
references.
Q16) What is a correlation name?
A16) A correlation name is a special type of column designator that connects spe
cific columns in the
various levels of a
multilevel SQL query.
Q17) What is a results table?
A17) A result table is the product of a query against one or more tables or view
s (i.e., it is the place that
holds the results of a
query).
Q18) What is a cursor?
A18) A cursor is a named control structure used to make a set of rows available
to a program. DB2 is the
relational database
system that runs in an MVS environment. It was developed by IBM and interfaces w
ith SQL. With
the use of SQL
DB2, databases can be accessed by a wide range of host languages. SQL is the rel
ational database "
application
Page 60 of 260 IBMMAINFRAMES.com
language " that interfaces with DB2. Because of its capabilities, SQL and, in tu
rn, DB2 have gained
considerable
acceptance. Thus, a working knowledge of DB2 increases one's marketability.
Q19) What is the basic difference between a join and a union?
A19) A join selects columns from 2 or more tables. A union selects rows.
Q20) What is normalization and what are the five normal forms?
A20) Normalization is a design procedure for representing data in tabular format
. The five normal forms
are progressive
rules to represent the data with minimal redundancy.
Q21) What are foreign keys?
A21) These are attributes of one table that have matching values in a primary ke
y in another table,
allowing for relationships
between tables.
Q22) Describe the elements of the SELECT query syntax?
A22) SELECT element FROM table WHERE conditional statement.
Q23) Explain the use of the WHERE clause?
A23) WHERE is used with a relational statement to isolate the object element or
row.
Q24) What techniques are used to retrieve data from more than one table in a sin
gle SQL
statement?
A24) Joins, unions and nested selects are used to retrieve data.
Q25) What is a view? Why use it?
A25) A view is a virtual table made up of data from base tables and other views,
but not stored separately.
Q26) Explain an outer join?
A26) An outer join includes rows from tables when there are no matching values i
n the tables.
Q27) What is a subselect? Is it different from a nested select?
A27) A subselect is a select which works in conjunction with another select. A n
ested select is a kind of
subselect where the
inner select passes to the where criteria for the outer select.
Q28) What is the difference between group by and order by?
A28) Group by controls the presentation of the rows, order by controls the prese
ntation of the columns for
the results of the
SELECT statement.
Q29) What keyword does an SQL SELECT statement use for a string search?
A29) The LIKE keyword allows for string searches. The % sign is used as a wildca
rd.
Q30) What are some SQL aggregates and other built-in functions?
A30) The common aggregate, built-in functions are AVG, SUM, MIN, MAX, COUNT and
DISTINCT.
Q31) How is the SUBSTR keyword used in SQL?
A31) SUBSTR is used for string manipulation with column name, first position and
string length used as
arguments. E.g.
SUBSTR (NAME, 1 3) refers to the first three characters in the column NAME.
Q32) Explain the EXPLAIN statement?
A32) The explain statement provides information about the optimizer's choice of
access path of the SQL.
Page 61 of 260 IBMMAINFRAMES.com
Q33) What is referential integrity?
A33) Referential integrity refers to the consistency that must be maintained bet
ween primary and foreign
keys, i.e. every
foreign key value must have a corresponding primary key value.
Q34) What is a NULL value? What are the pros and cons of using NULLS?
A34) A NULL value takes up one byte of storage and indicates that a value is not
present as opposed to a
space or zero
value. It's the DB2 equivalent of TBD on an organizational chart and often corre
ctly portrays a
business situation.
Unfortunately, it requires extra coding for an application program to handle thi
s situation.
Q35) What is a synonym? How is it used?
A35) A synonym is used to reference a table or view by another name. The other n
ame can then be written
in the
application code pointing to test tables in the development stage and to product
ion entities when the
code is migrated.
The synonym is linked to the AUTHID that created it.
Q36) What is an alias and how does it differ from a synonym?
A36) An alias is an alternative to a synonym, designed for a distributed environ
ment to avoid having to use
the location
qualifier of a table or view. The alias is not dropped when the table is dropped
.
Q37) When can an insert of a new primary key value threaten referential integrit
y?
A37) Never. New primary key values are not a problem. However, the values of for
eign key inserts must
have
corresponding primary key values in their related tables. And updates of primary
key values may
require changes in
foreign key values to maintain referential integrity.
Q38) What is the difference between static and dynamic SQL?
A38) Static SQL is hard-coded in a program when the programmer knows the stateme
nts to be executed.
For dynamic SQL
the program must dynamically allocate memory to receive the query results.
Q39) Compare a subselect to a join?
A39) Any subselect can be rewritten as a join, but not vice versa. Joins are usu
ally more efficient as join
rows can be
returned immediately, subselects require a temporary work area for inner selects
results while
processing the outer
select.
Q40) What is the difference between IN subselects and EXISTS subselect?
A40) If there is an index on the attributes tested an IN is more efficient since
DB2 uses the index for the
IN. (IN for index is
the mnemonic).
Q41) What is a Cartesian product?
A41) A Cartesian product results from a faulty query. It is a row in the results
for every combination in the
join tables.
Q42) What is a tuple?
Page 62 of 260 IBMMAINFRAMES.com
A42) A tuple is an instance of data within a relational database.
Q43) What is the difference between static and dynamic SQL?
A43) Static SQL is compiled and optimized prior to its execution; dynamic is com
piled and optimized
during execution.
Q44) Any SQL implementation covers data types in couple of main categories. Whic
h of the
following are those data
types ? (Check all that apply)
A). NUMERIC
B). CHARACTER
C). DATE AND TIME
D). BLOBS E. BIT
A44) A,B,C. Not all SQL implementations have a BLOB or a BIT data types.
Q45) We have a table with a CHARACTER data type field. We apply a ">" row compar
ison
between this field and
another CHARACTER field in another table. What will be the results for records w
ith field
value of NULL?
(Check one that applies the best)
A.
TRUE
B.
B. FALSE
C.
C. UNKNOWN
D.
D. Error.
E. E. Those records will be ignored
A45) C. NULL in a row when compared will give an UNKNOWN result.
Q46) Any database needs to go through a normalization process to make sure that
data is
represented only once. This
will eliminate problems with creating or destroying data in the database. The no
rmalization
process is done
usually in three steps which results in first, second and third normal forms. Wh
ich best
describes the process to
obtain the third normal form? (Check one that applies the best)
A.
Each table should have related columns.
B.
Each separate table should have a primary key.
C.
We have a table with multi-valued key. All columns that are dependent on only on
e or on some
of the keys should be moved in a different table.
D.
If a table has columns not dependent on the primary keys, they need to be moved
in a separate
table.
E. E. Primary key is always UNIQUE and NOT NULL.
A46) D. All columns in a table should be dependent on the primary key. This will
eliminate transitive
dependencies in
which A depends on B, and B depends on C, but we're not sure how C depends on A.
Q47) SQL can be embedded in a host program that uses a relational database as a
persistent data
repository. Some of
the most important pre-defined structures for this mechanism are SQLDA ("SQL Des
criptor
Area") and
SQLCA ("SQL Communications Area") SQLCA contains two structures -SQLCODE and
SQLSTATE.
SQLSTATE is a standard set of error messages and warnings in which the first two
characters
defines the class
Page 63 of 260
IBMMAINFRAMES.com
and the last three defines the subclass of the error. Which of the following SQL
STATE codes is
interpreted as
"No data returned"?(Check one that applies the best)
A). 00xxx
B). 01xxx
C). 02xxx
D). 22xxx
E). 2Axxx