Wednesday, July 18, 2007

JCL Technical FAQ's

COBOL IMS VSAM
DB2 JCL CICS


Q What is JCL ?
A JCL stands for Job Control Language


Q What is the difference between keyword and positional parameters ?
A Positional parameters are characterized by their position in the operand field in relation to other parameters.
Keyword parameters are positionally independent with respect to others of their type and consisting of a keyword followed by an equal sign and variable information.


Q What is a DISP ?
A DISP is a keyword parameter which is defined on the DD statement and which consist of the following positional subparameters: DISP=(Status, Normal Disp, Abnormal Disp). The DISP parameter describes the current status of the dataset (old, new, or modified) and directs the system on the disposition of the data set (pass, keep, catalog, uncatalog, or delete) either at the end of the step or if the step abnormally terminates. DISP is always required unless the data set is created and deleted in the same step.


Q What is DISP=SHR ?
A DISP=SHR permits old data sets to be shared. SHR is identical to OLD except that several jobs may read the dataset concurrently in multiprogramming environments. SHR must be used only for input data sets; use OLD or MOD if data set is modified. Sharing data set is necessary because public libraries like SYS1.LINKLIB or the subroutine libraries should be available to every job in the system.


Q What is DISP=MOD ?
A DISP=MOD modifies a sequential data set. It is a convenient way to add data to the end of sequential dataset. If the data set doesn't exist, the system changes MOD to NEW unless the VOL parameter request specific volume. When VOL is coded, the stem expects to find data set on the specified volume and terminates the step if it cannot find it. MOD is the usual way of extended data sets in to several direct-access volumes.


Q What is DISP=PASS ?
A PASS passes the data set on to subsequent job steps, and each step can use the data set once. It is a positional subparameter of the DISP which could only be specified under normal termination action. Pass saves time because the system retains the data set location and volume information.


Q What are the parameters that have to be coded on a DD statement in order to retrieve a cataloged data set ?
A The minimum parameters needed are DSN and DISP.


Q How does the system get information about the block size ?
A DCB info comes from :-
1) Program - FD: BLOCK CONTAINS 3 RECORDS RECORD CONTAINS 100 CHARACTERS
2) The label - like a tape
3) From the VTOC - for Dasd
4) From the JCL - DCB=BLKSIZE=nnn.


Q What is a Label ?
A LABEL is a keyword parameter which can be specified on DD statement and consists of the following subparameters:
LABEL=(Relative File #, Type of Label Processing)
The LABEL parameter tells the type of label, the relative file number,and whether the data set is to be protected for input or output.


Q When should be NL be specified as a type of label processing ?
A NL should be specified when a program needs to process unlabeled tapes NL can also be specified when the pgm wants to create unlabeled tape because the system's default action, in cases when parameter is not specified, will create IBM standard label. Nonlabeled tapes are often used for sending tapes to another installation. That way you don't have to worry about the tape label corresponding to the standards at the other installation or about accidentally matching the volume serial number of an existing tape at the installation.


Q How do you describe the input data which is a part of the input job stream ?
A You should use either DD * or DD Data.


Q What is the difference between * and Data ?
A DD * and DD DATA describe the input data which follows the above mention cards. If the input data contains record switch // in col 1 and 2 then DD Data should be used.


Q What is the purpose of SPACE parameter ?
A It is a keyword parameter which should allocated on the DD statement for the output data sets stored on the disk.It consists of the following subparameters:
SPACE=(BLKS/CYL/TRK,(primary,secondary,index),RLSE,CONTIG)


Q What is a RLSE ?
A RLSE releases all unused space when the data set is closed. It permits you to allocate more space than perhaps, it needed without wasting space. Space is released only if the data set is not empty and if the data set is closed after being opened.


Q What is a CONTIG ?
A CONTIG requests the primary space be allocated only on contiguous tracks and cylinders, that is all tracks on a cylinder are contiguous, and if more than one cylinder is needed, the cylinders are also contiguous. Always code CONTIG if track overflow is used.


Q What is a PDS ?
A PDS is a library type of data set organization consisting of Directory and Members. The directory consists of blocks, and each block is 256 bytes in length and can hold up to 5 members. Each member of the PDS is a sequential data set.


Q What is a Temporary Data Set ?
A Temporary data sets are used for storage needed only for the duration of the job. If the DISP parameter doesn't delete the data set by the end of the job, the system will delete it. Deleting a tape data set dismounts the tape, whereas deleting a dataset on a direct-access volume release the storage. A data set is marked temporary by omitting the DSN parameter or by coding DSN=&&dsname. The system assign a unique name to the data set when the DSN parameter is omitted, and any subsequent steps using the dataset refer back to the DD statement.


Q What is COND parameter ?
A It is a keyword parameter which can be specified on the JOB or EXEC statements. COND consists of 3 subparameters:
code(0 thru 4095),logical operator, and stepname of the step that is going to be compared.
The purpose of the COND is to determine whether the step should be executed or bypassed. If condition specified in the COND parameter is true,the step is bypassed.


Q How do you specify a COND parameter for a job step so that the step will never be executed ?
A COND=(0,LE) or COND=(4095,GE).


Q What does COND=ONLY mean ?
A It means that this job step will be executed only if a previous step had abnormally terminated.


Q What does COND=EVEN mean ?
A It means that this jobs step will be executed even if a previous step abnormally terminated.


Q What is a NAME ?
A Name is a positional parameter which identifies the person or group responsible for a job.


Q What is a PRIORITY ?
A It is a keyword parameter which specifies a job initiation priority within its job class. When the job is initiated, the system will convert the job's priority into a dispatching priority so that job's task can complete with other tasks for use of main storage and CPU resources.


Q How does the system determine the priority of a job for execution ?
A First the system determines which job has the highest class. Each class has a job queue with jobs of different priorities. The system will select the job for execution that has the highest PRTY (0 thru 15) 15 is the highest priority.


Q What is a MSGCLASS parameter ?
A It is a keyword parameter which specifies the output class to which system messages for your job are to be routed. Output class is an alphabetic (A thru Z) or numeric (0 thru 9) character. The default for MSGCLASS parameter will be A. System messages and output data sets can be routed to the same output class. You can code the MSGCLASS parameter in the Job statement and the SYSOUT parameter on the DD statement.


Q What is MSGLEVEL parameter ?
A It is a keyword parameter which indicates what job output is to be written as a part of output listing. The following outputs can be requested: the Job statement;
all input job control statements;
allocation, disposition and allocation recovery messages(allocation/termination message)
MSGLEVEL=(statements, messages)
Statements:
- 0 - only the job statement is to be written;
- 1 - all input control statements, cataloged procedure statements and the internal representation of procedure statement parameters after symbolic parameters substitution are to be written;
- 2 - only input job control statements are to be written;
Messages:
- 0 - No allocation/termination messages are to be printed unless the job terminates abnormally;
- 1 - All allocation/termination messages are to be printed.


Q How can you check for syntax or JCL errors without actual execution of a job ?
A TYPRUN=SCAN should be specified on a job card


Q What is the difference between the COND parameter specified on the EXEC statement and the one specified on the JOB statement ?
A COND parameter specified on EXEC statement determines whether step should be bypassed or executed.
COND parameter defined on the JOB statement will determine whether Job should be terminated at a certain point or continued. When COND parameter is defined on the JOB statement, the system evaluates condition specified in the COND parameter before beginning of any job step and compares the code specified in the COND parameter with the return code of all previous jobsteps. If that condition is true, the rest of the job steps are bypassed.

MAINFRAME - COBOL INTERVIEW QUESTIONS





MAINFRAME - COBOL INTERVIEW QUESTIONS

  1. Name the divisions in a COBOL program.

    IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.

  2. What are the different data types available in COBOL?

    Alpha-numeric (X), alphabetic (A) and numeric (9).

  3. What does the INITIALIZE verb do? –

    Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES.

    Numeric, Numeric edited items set to ZERO.

    FILLER , OCCURS DEPENDING ON items left untouched.

  4. What is 77 level used for ?

Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.

  1. What is 88 level used for ?

    For condition names.

  2. What is level 66 used for ?

    For RENAMES clause.

  3. What does the IS NUMERIC clause establish ?

    IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and usigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .

  4. How do you define a table/array in COBOL?

    01 ARRAYS.

    05 ARRAY1 PIC X(9) OCCURS 10 TIMES.

    05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

  5. Can the OCCURS clause be at the 01 level?

    No.

  6. What is the difference between index and subscript?

    Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET.

    Need to have index for a table in order to use SEARCH, SEARCH ALL.

  7. What is the difference between SEARCH and SEARCH ALL?

    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.

  8. What should be the sorting order for SEARCH ALL?

    It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an 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).

  9. What is binary search?

    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 where the item lies.

  10. 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?

    Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.

  11. How do you sort in a COBOL program? Give sort file definition, sort statement syntax and meaning.

    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 workfile and must be described using SD entry in FILE SECTION.

    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 outfile 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 the sort work file must be RETURNed one at a time to the output procedure.

  12. How do you define a sort file in JCL that runs the COBOL program?

    Use the SORTWK01, SORTWK02,..... dd names in the step. Number of sort datasets depends on the volume of data being sorted, but a minimum of 3 is required.

  13. What are the two ways of doing sorting in a COBOL program? Give the formats.

    See question 16.

  14. Give the format of USING and GIVING in SORT statement. What are the restrictions with it?

    See question 16. Restrictions - Cannot massage records, canot select records to be sorted.

  15. What is the difference between performing a SECTION and a PARAGRAPH?

    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.

  16. What is the use of EVALUATE statement?

    Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.

  17. What are the different forms of EVALUATE statement?

    EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS

    WHEN A=B AND C=D WHEN 100 ALSO '00'

    imperative stmt imperative stmt

    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

    EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE

    WHEN 100 ALSO TRUE WHEN 100 ALSO A=B

    imperative stmt imperative stmt

    WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)

    imperative stmt imperative stmt

    END-EVALUATE END-EVALUATE

  18. How do you come out of an EVALUATE statement?

    After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code.

  19. In an EVALUATE statement, can I give a complex condition on a when clause?

    Yes.

  20. What is a scope terminator? Give examples.

    Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.

  21. How do you do in-line PERFORM?

    PERFORM ... ...

    END PERFORM

  22. When would you use in-line perform?

When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code (used from various other places in the program), it would be better to put the code in a separate para and use PERFORM paraname rather than in-line perform.

27. What is the difference between CONTINUE & NEXT SENTENCE ?

CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period)

  1. What does EXIT do ?

    Does nothing ! If used, must be the only sentence within a paragraph.

  2. Can I redefine an X(100) field with a field of X(200)?

    Yes. Redefines just causes both fields to start at the same location. For example:

    01 WS-TOP PIC X(1)

    01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).

    If you MOVE '12' to WS-TOP-RED,

    DISPLAY WS-TOP will show 1 while

    DISPLAY WS-TOP-RED will show 12.

  3. Can I redefine an X(200) field with a field of X(100) ?

    Yes.

  4. What do you do to resolve SOC-7 error?

    Basically you need to correcting the offending data.

    Many times the reason for SOC7 is an un-initialized numeric item. Examine that possibility first.

    Many installations provide you a dump for run time abends ( it can be generated also by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL.

    If none of these are helpful, use judgement and DISPLAY to localize the source of error.

    Some installtion might have batch program debugging tools. Use them.

  5. How is sign stored in Packed Decimal fields and Zoned Decimal fields?

    Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage.

    Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite.

  6. How is sign stored in a comp-3 field?

    It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is -102 etc...

  7. How is sign stored in a COMP field ?

    In the most significant bit. Bit is on if -ve, off if +ve.

  8. What is the difference between COMP & COMP-3 ?

    COMP is a binary storage format while COMP-3 is packed decimal format.

  9. What is COMP-1? COMP-2?

    COMP-1 - Single precision floating point. Uses 4 bytes.

    COMP-2 - Double precision floating point. Uses 8 bytes.

  10. How do you define a variable of COMP-1? COMP-2?

    No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

  11. How many bytes does a S9(7) COMP-3 field occupy ?

    Will take 4 bytes. Sign is stored as hex value in the last nibble.

    General formula is INT((n/2) + 1)), where n=7 in this example.

  12. How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

    Will occupy 8 bytes (one extra byte for sign).

  13. How many bytes will a S9(8) COMP field occupy ?

    4 bytes.

  14. What is the maximum value that can be stored in S9(8) COMP?

    99999999

  15. What is COMP SYNC?

    Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT.

    For binary data items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my first variable is x(3) and next

    one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4. You might see some wastage of memory, but the access to this

    computational field is faster.

  16. What is the maximum size of a 01 level item in COBOL I? in COBOL II?

    In COBOL II: 16777215

  17. How do you reference the following file formats from COBOL programs:

    Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0 .

    Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS

    Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4

    Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4.

    ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL.

    KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS

    RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS

    Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).

  18. What are different file OPEN modes available in COBOL?

    Open for INPUT, OUTPUT, I-O, EXTEND.

  19. What is the mode in which you will OPEN a file for writing?

    OUTPUT, EXTEND

  20. In the JCL, how do you define the files referred to in a subroutine ?

    Supply the DD cards just as you would for files referred to in the main program.

  21. Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?

    Can rewrite(record length must be same), but not delete.

  22. What is file status 92?

    Logic error. e.g., a file is opened for input and an attempt is made to write to it.

  23. What is file status 39 ?

    Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You will get file status 39 on an OPEN.

  24. What is Static,Dynamic linking ?

    In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).

    A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.

  25. What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? ( applicable to only

MVS/ESA Enterprise Server).

These are compile/link edit options.

AMODE - Addressing mode. RMODE - Residency mode.

AMODE(24) - 24 bit addressing. AMODE(31) - 31 bit addressing. AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE.

RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only).

RMODE(ANY) - Can reside above or below 16 Meg line.

  1. What compiler option would you use for dynamic linking?

    DYNAM.

  2. What is SSRANGE, NOSSRANGE ?

    These are compiler options w.r.t 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 permissible range.

  3. How do you set a return code to the JCL from a COBOL program?

    Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.

  4. How can you submit a job from COBOL programs?

    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.

  5. What are the differences between OS VS COBOL and VS COBOL II?

    OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can run either in 24 bit or 31 bit addressing modes.

    Report writer is supported only in OS/VS Cobol.

    USAGE IS POINTER is supported only in VS COBOL II.

    Reference modification eg: WS-VAR(1:2) is supported only in VS COBOL II.

    EVALUATE is supported only in VS COBOL II.

    Scope terminators are supported only in VS COBOL II.

    OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.

    Under CICS Calls between VS COBOL II programs are supported.

  6. What are the steps you go through while creating a COBOL program executable?

    DB2 precompiler (if embedded sql used), CICS translator (if CICS pgm), Cobol compiler, Link editor.

    If DB2 program, create plan by binding the DBRMs.

  7. Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?

In non-CICS environment, it is possible. In CICS, this is not possible.


COBOL Technical FAQ's

COBOL IMS VSAM
DB2 JCL CICS


Q How many different level numbers can be used in COBOL to describe a record?
A 01-49.
Q What is level 88?
A The level 88 in the Data Division can be used to give condition names to the values that a field contain. When this level is specified you can use the condition name instead of is = to in the IF statement. Condition name should be specified under Level 88 immediately following the field description.
Q What is the difference between level 77 and 01? and which is more efficient?
A Level 77 can be used to describe independent elementary items in the Working-Storage or Linkage Sections.
Level 01 can be used to describe both elementary and group items. Any item described in Level 01, the system is putting on Double-Word boundary and inserts slack bytes if necessary
Q Name the different PERFORM statement?
A PERFORM
PERFORM THRU
PERFORM 'n' of TIMES
PERFORM UNTIL
PERFORM VARYING with UNTIL Option.
Q What is the Structured Programming and how do you identify it?
A The difference between regular programming approach and structured programming is that structured programs get rid of GO TO statements and the whole programs can be represented in a Top-Down design. This design is possible because of existence of 3 basic structures:
a. Sequence Structure: within sequence structure all functions are executed in their physical order. The structure has one entry point and one exit point.

b. Selection Structure: within selection structure execution of the function depends on whether conditions true or false. The structure has one entry point and one exit point.
c. Iteration Structure: within iteration structure the execution of the function will be reiterated over and over again until condition becomes true. The structure has one entry point and one exit point. All these structures have one entry point and one exit point. Because of this if the programs is written by using only these structures, the whole programs will have one entry point and one exit point.
Q What are advantages of Structured Programming?
A The programs gets rid of GO TO statements and is represented by Top-Down Structure which is visible and easy to understand, because the programs has a specific (hierarchical) structure, it is easy to debug the programs.
Q What is a subscript?
A Subscript represents occurrence # of the Table Entry. Subscript can be represented explicitly and implicitly. Explicitly means thru occurrence # of the table entry; implicitly means thru a data name. That data name should be defined as an independent item in the W-S Section. The most efficient definition of Subscript is Full-Word binary.
Q What is an index?
A Index is assigned to specific table thru INDEXED BY clause. Internally is represented by Index Register which is Full-Word binary. Specific index name can be used to reference a field from the table to which that index is assigned to index represents displacement value of the table entry from the beginning of the table.
Q What is the difference between Subscript and Index?
A Index represent displacement value of the table entry from the beginning of the table, subscript - occurrence # of the table entry. To calculate the displacement of the table entry from its beginning when subscript is used takes 16 additional instructions from the system because of that the usage of the index is more efficient.
Q What are the different ways of an internal table search?
A a. Sequential Search statement. (SEARCH)
b. Binary search statement.(SEARCH ALL)
Q What is the difference between SEARCH and SEARCH ALL?
A Serial search (SEARCH) examines each table entry starting at the beginning, whereas a binary search (SEARCH ALL) starts looking at the mid-point of the table and works its way toward the argument depending upon if its too high or too low. A serial search can be used for unsorted tables, while a binary search is only useful if the tables is sorted.
Q How do change the value of an index in a COBOL programs?
A A SET statement.
Q How many different data USAGEs can be used in COBOL?
A DISPLAY, COMP, COMP-3, INDEX, POINTER.
Q What is a USAGE IS INDEX?
A USAGE IS INDEX represents an index data item which is Full-Word binary and is used to save the value of the index. That Index Data Item can be set to the value of the Index thru the SET statement, ex. SET WS-IND-SAVE-FLD TO ITEM-IND. Index data item is not directly related to any table.
Q What is AMODE and RMODE? What does 24 or 31 mean to it?
A Addressing Mode/Access Mode
AMODE(24) indicates 24-bit (three-byte) addressing - memory below the line.
AMODE(31) indicates 31-bit addressing - memory above and below the line.
AMODE=ANY indicates the program may use either of the addressing technique.
Run Mode/Residency Mode
RMODE(24) indicates that the program must be loaded into memory below the line
RMODE(31) indicates that the program can be loaded either below or above the line.
RMODE=ANY indicates that the program can be run in either 24 bit (below)or 31 bit memory (above).
Q What is the difference between static call and dynamic call in Cobol?
A A statically called program is link-edited into the same load module as the calling program, a static call is faster than a dynamic call. A static call is the preferred method if your application does not require the services of the dynamic call.
Statically called programs cannot be deleted (using CANCEL), so static calls might take more main storage. If storage is a concern, think about using dynamic calls. Storage usage of calls depends on whether:
The subprogram is called only a few times. Regardless of whether it is called, a statically called program is loaded into storage; a dynamically called program is loaded only when it is called.
You subsequently delete the dynamically called subprogram with a CANCEL statement.
You cannot delete a statically called program, but you can delete a dynamically called program. Using a dynamic call and then a CANCEL statement to delete the dynamically called program after it is no longer needed in the application (and not after each call to it) might require less storage than using a static call.

DB2 Technical FAQ's

COBOL IMS VSAM
DB2 JCL CICS


Q What are the different data types in DB2?
A Smallint
Integer
DECIMAL
FLOAT
Character,Varcharacter
Graphic,Vargraphic
Date
Time
Timestamp
Q What is a view ? What are the advantages and restrictions of using a view ?
A A view is a virtual table derived from one or more base tables. It prevents unauthorized users from having access to sensitive data. Cannot insert, delete or update a view, which is based on more than one base table.


Q What do you mean by referential Integrity?
A Referential integrity is a condition wherein all references from one table to another are valid. It is the enforcement of all referential constraints(a rule that the value of a foreign key must appear as the value of a primary key of some other specific table.)


Q What is a Subquery ?
A A subquery is a query that is written as part of another query's WHERE clause.


Q What is corrleated subquery ?
A A correlated subquery is one that has a correlation name as a table or view designator in the FROM clause of the outer query and the same correlation name as qualifier of a search condition in the WHERE clause of the subquery.


Q How does the processing of correlated subquery differ from a noncorrelated ?
A The subquery in a correlated subquery is reevaluated for every row of the table or view named on the outer query, while the subquery Of a noncorrelated subquery is evaluated only once.


Q What is DB2 bind ?
A A bind is a process that builds 'access paths' to DB2 tables. A bind uses the Database Request module(s) from the DB2 precompile step as input and produces an application plan. It also checks the user's authority and validates the SQL Statements in the DBRM.


Q What is a plan?
A A plan is a DB2 (produced during the bind process) that associates one or more database request modules with a plan name.


Q What is a synonym? How is it used?
A A synonym is used to reference a table or view by another name. The other name can then be written in the application code pointing to test tables in the development stage and to production entities when the code is migrated.The synonym is linked to the AUTHID that created it.


Q What is an alias and how does it differ from a synonym?
A An alias is an alternative to a synonym, designed for a distributed environment to avoid having to use the location qualifier of a table or view. The alias is not dropped when the table is dropped.


Q Describe the primary key and the foreign key?
A The primary key is a column or a set of columns that provide a unique identifier to each row of a table. The foreign key is a column or a set of columns that refers to the primary key of another table.


Q What is DDL and DML?
A DDL - Data Definition Language (CREATE, ALTER, TRUNCATE)
DML - Data Manipulation Language (SELECT, INSERT, DELETE & UPDATE)


Q What is DCLGEN?
A DCLGEN stands for declarations generator; it is a facility to generate DB2 sql data structures in COBOL or PL/I programs.


Q What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?
A The clause avoids closing the cursor and repositioning it to the last row processed when the cursor is reopened.


Q What are the three lock types?
A The three types are shared, update and exclusive. Shared locks allow two or more programs to read simultaneously but not change the locked space.An exclusive lock bars all other users from accessing the space.An update lock is less restrictive; it allows other transactions to read or acquire shared locks on the space.


Q What is deadlock ?
A Deadlock occurs when transactions executing at the same time lock each other out of data that they need to complete their logical units of work.


Q What is the difference between group by and order by ?
A Group by controls the presentation of the rows, order by controls the presentation of the columns for the results of the SELECT statement.


Q What is a clustered index ?
A For a clustered index DB2 maintains rows in the same sequence as the columns in the index for as long as there is free space. DB2 can then process that table in that order efficiently.


Q What is the equivalent cobol definiton for the datatypes in DB2 ?
A Smallint - S9(4) COMP or S9(4) COMP-4
Integer - S9(9) COMP or S9(9) COMP-4
Char(N) - PIC X(N)
Varchar(N) - 01 NAME.
49 NAME-LEN PIC S9(4) USAGE COMP.
49 NAME-TEXT PIC X(N).
DECIMAL(P,S) - If p<19: S9(p-s)V9(s) COMP-3
Float - USAGE COMP-2
Date - pic x(10).
Timestamp - pic x(26).


Q How do you add columns to an existing table ?
A ALTER table command can be used to add columns to an existing table.


Q What is SPUFI & QMF ?
A SPUFI - Sql Processing Using File Input
QMF - Query Management Facility

Both of them are DB2 interactive menu-driven tools used by developers to create & modify database objects.


Q Name a few utilities available in DB2 ?
A LOAD
MERGE
MODIFY
QUIESCE
REBUILD
RECOVER
REORG
REPORT
REPAIR
RUNSTATS


Q What are the different COLUMN functions ?
A SUM-Returns the total value.
MIN-Returns the minimum value.
AVG-Returns the average value.
MAX-Returns the maximum value.
COUNT-Returns the number of selected rows.
STDDEV-Returns the standard deviation of the column values.
VARIANCE- Returns the variance of the column values.


Q What is a scalar function ?
A A scalar function also produces a single value, but unlike the argument of a column function, an argument of a scalar function is a single value.


Q what is a COLUMN function ?
A A column function produces a single value for a group of rows. You can use the SQL column functions to calculate values based on entire columns of data. The calculated values are from selected rows only (all rows that satisfy the WHERE clause).


Q What are the different types of Table spaces ?
A Simple Table Space
Segmented Table Space
Partitioned Table Space


Q What is Cursor Stability(CS) ?
A A page lock is held only while the cursor is positioned on that page. When the cursor moves to another page, the lock is released. When a page is locked concurrent application programs cannot update or delete a row of the locked page. The current lock is not released until a new lock is acquired. If an application program updates or deletes data, the lock is held until the data is committed. CS applies only to data that is read. All changed data remains locked until COMMIT or ROLLBACK.


Q What is the purpose of a null indicator variable? and what are the possible values in the variable and what do they mean ?
A A Null Indicator is used to indicate whether the host variable has been assigned a null. It used to indicate whether a retrieved character value has been truncated. It is used to set a column to null. The indicator value of –1 means the associated host variable contains null. 0 means the associated host variable does not contain null, nor the returned value is truncated. –2 means the associated host variable contains null due to a numeric or arithmetic conversion error. >0 means the value assigned to the host variable is truncated. The value represented by the indicator variable is the actual length of the character value before truncation.


Q What is commit and rollback ?
A A commit occurs automatically at the end of the program, or by request one or more times during the execution of the program. Releases all locks acquired by the program since the last commit, so that other programs and users may obtain access to the data. Any open cursors are automatically closed. All database changes are made permanent.If any changes made to the tables are not appropriate, then all the changes must by rolled back resulting in the same state of data as they were prior to making changes. Release all locks acquired by the program.