👁 0
Q: What is the difference between COMP and COMP-3 in COBOL?
Answer:
COMP (COMPUTATIONAL) - Pure binary format
- Stored in binary (base-2)
- Used for subscripts and counts
- Efficient for arithmetic operations
- PIC S9(4) COMP = 2 bytes
- PIC S9(9) COMP = 4 bytes
COMP-3 (PACKED DECIMAL)
- Each digit takes 4 bits (nibble)
- Last nibble holds sign
- Used for business calculations
- PIC S9(5) COMP-3 = 3 bytes
- Formula: (n+1)/2 rounded up
When to use:
- COMP - Array subscripts, counters, loops
- COMP-3 - Money, quantities, business data
👁 0
Q: What is ROW_NUMBER()?
Answer:
ROW_NUMBER() assigns sequential numbers. ROW_NUMBER() OVER (ORDER BY col). Numbers restart per PARTITION BY group. Use for paging, deduplication (keep first), ranking. Result is numeric.
👁 0
Q: What are the four divisions of a COBOL program?
Answer:
- IDENTIFICATION DIVISION - Program identification (PROGRAM-ID)
- ENVIRONMENT DIVISION - Hardware/software environment, file assignments
- DATA DIVISION - Data definitions (FILE, WORKING-STORAGE, LINKAGE SECTION)
- PROCEDURE DIVISION - Executable code and business logic
Only IDENTIFICATION and PROCEDURE DIVISION are mandatory.
👁 0
Q: What is the difference between COMP and COMP-3?
Answer:
COMP (Binary) stores data in binary format, taking 2, 4, or 8 bytes. COMP-3 (Packed Decimal) stores two digits per byte with the sign in the last nibble, more efficient for decimal arithmetic. COMP is faster for calculations while COMP-3 saves space for large decimal numbers.
👁 0
Q: Explain predicate types
Answer:
Stage 1 predicates evaluated by storage engine. Stage 2 evaluated by DB2 (more expensive). Indexable predicates can use index. Non-indexable force scan. Design for stage 1/indexable predicates. EXPLAIN shows predicate staging.
👁 0
Q: What is index-only access?
Answer:
Index-only access retrieves data from index without table access. All needed columns in index (including by include clause). Best performance. EXPLAIN shows INDEXONLY=Y. Design indexes for common queries.
👁 0
Q: Explain database design normalization
Answer:
1NF: atomic values, no repeating groups. 2NF: 1NF + no partial dependencies. 3NF: 2NF + no transitive dependencies. BCNF: stricter 3NF. Higher forms reduce redundancy. Denormalize for performance. Balance is key.
👁 0
Q: What is referential integrity?
Answer:
RI ensures foreign key values exist in parent. CREATE TABLE child ... REFERENCES parent(key). ON DELETE CASCADE/SET NULL/RESTRICT. DB2 enforces automatically. Constraint violations return -530/-531. Design carefully.
👁 0
Q: How to handle packed decimal data?
Answer:
Packed decimal (COMP-3) stores 2 digits per byte, sign in low nibble. PIC S9(5) COMP-3 uses 3 bytes. For I/O, often must convert to display. Use MOVE to display field or NUMVAL function. Handle sign separately if needed.
👁 0
Q: What is PIC clause editing?
Answer:
Picture editing characters: Z=zero suppress, *=check protect, +=sign, -=negative, CR/DB=credit/debit, $=currency, .=decimal, ,=comma, B=blank. Example: PIC ,ZZ9.99- displays $ 123.45-. Insertion characters add to display.
👁 0
Q: Explain DE-EDIT function
Answer:
FUNCTION DE-EDIT converts edited numeric back to numeric. Original: '1,234.56-'. DE-EDIT result: -1234.56. Removes edit characters, preserves numeric value and sign. Useful when receiving edited display data needing calculation.
👁 0
Q: Explain SYMBOLIC CHARACTERS
Answer:
SPECIAL-NAMES. SYMBOLIC CHARACTERS NULL-CHAR IS 1. Assigns name to ordinal position in collating sequence. Position 1 is X'00' in EBCDIC. Use: MOVE NULL-CHAR TO field. Define non-printable characters readably.
👁 0
Q: How to define FILE-CONTROL?
Answer:
SELECT file-name ASSIGN TO ddname. ORGANIZATION IS INDEXED. ACCESS MODE IS DYNAMIC. RECORD KEY IS key-field. ALTERNATE RECORD KEY IS alt-key. FILE STATUS IS ws-status. Maps COBOL file to physical dataset.
👁 0
Q: What is STORAGECLASS?
Answer:
SMS STORAGECLASS for VSAM placement. STORCLAS on DEFINE. Controls performance, availability. ACS routines may assign. Modern storage management. Replaces explicit volume specifications.
👁 0
Q: What is pseudo-conversational programming?
Answer:
Pseudo-conversational ends task after sending screen, restarts on input. EXEC CICS RETURN TRANSID(trans) COMMAREA(data). Saves resources - no task waiting for user. Must restore state from COMMAREA. Standard CICS approach.
👁 0
Q: How to use SET statement?
Answer:
SET symbol=value assigns value. SET DATE=&LYYMMDD (system symbol). Multiple: SET A=1,B=2. Scope: job/proc. Override on EXEC. SET can reference other symbols. Evaluated at conversion time. Enables parameter files.
👁 0
Q: What is SYSID?
Answer:
SYSID identifies CICS system. 4-character name. EXEC CICS ASSIGN SYSID(ws-sysid). Or in RDO definitions. Used for MRO routing, function shipping. Remote file/program SYSID option.
👁 0
Q: What is PERFORM parameter?
Answer:
PERFORM assigns service class. PERFORM=n (1-999). JES/WLM determines resource allocation. Higher may get more resources. Installation dependent. Modern systems use WLM service classes instead.
👁 0
Q: What is DATACLAS parameter?
Answer:
DATACLAS assigns SMS data class. DATACLAS=classname. Defines DCB attributes, space, data type. ACS routines may assign automatically. Overrides explicit DCB. Simplifies JCL. Installation-defined classes.
👁 0
Q: What is RUNSTATS and when to use it?
Answer:
RUNSTATS collects table/index statistics for optimizer. Run after significant data changes (loads, deletes). Updates catalog tables (SYSTABLES, SYSINDEXES). Optimizer uses for access path selection. RUNSTATS TABLESPACE db.ts INDEX(ALL).
👁 0
Q: What is DISTINCT keyword?
Answer:
DISTINCT eliminates duplicate rows. SELECT DISTINCT col FROM table. Applies to entire row, not single column. Causes sort for duplicate elimination. Performance impact. Avoid if possible. Sometimes indicates bad design.
👁 0
Q: How to handle SMS conversion?
Answer:
SMS manages storage automatically. Migrate VSAM to SMS: DATACLAS, STORCLAS, MGMTCLAS. ACS routines for assignment. Remove explicit VOL/UNIT. Benefits: automation, management.
👁 0
Q: How to handle CICS timeout?
Answer:
Set RTIMOUT on transaction. EXEC CICS HANDLE CONDITION ERROR. DTIMOUT for deadlock. Program design for cleanup. TIMEOUT condition raised.
👁 0
Q: Explain RANK vs DENSE_RANK
Answer:
RANK() creates gaps for ties: 1,2,2,4. DENSE_RANK() no gaps: 1,2,2,3. ROW_NUMBER() no ties: 1,2,3,4. RANK useful for competition ranking. DENSE_RANK for level assignment. Choose based on need.
👁 0
Q: What are nested programs?
Answer:
Nested programs are contained within another COBOL program. Defined between IDENTIFICATION DIVISION and END PROGRAM. Can access outer program's data with GLOBAL clause. COMMON attribute allows access from sibling programs. Promotes modular design.
👁 0
Q: Explain storage group
Answer:
Storage group defines volumes for data. CREATE STOGROUP name VOLUMES(vol1, vol2). Tablespaces assigned to stogroups. DB2 manages space within. PRIQTY/SECQTY control allocation. Foundation of storage management.
👁 0
Q: Explain SPECIAL-NAMES paragraph
Answer:
SPECIAL-NAMES maps system names to COBOL names. DECIMAL-POINT IS COMMA for European notation. CURRENCY SIGN IS '$'. SYMBOLIC CHARACTERS name = value. ALPHABET for custom collating. CLASS for character groups.
👁 0
Q: Explain condition-name SET TRUE
Answer:
SET condition-name TO TRUE assigns the condition's VALUE. If 88 ACTIVE VALUE 'A', SET ACTIVE TO TRUE moves 'A' to parent. Cleaner than MOVE 'A' TO STATUS. Makes code self-documenting. Multiple values take first.
👁 0
Q: How to handle negative numbers?
Answer:
Sign stored in PIC S9. SIGN IS LEADING/TRAILING SEPARATE CHARACTER for explicit sign byte. COMP-3 sign in low nibble. Display: S9(5)- shows trailing minus. +9(5) shows sign always. DB/CR for accounting format.
👁 0
Q: How to handle status 96?
Answer:
Status 96 is no DD statement for file. Check JCL has correct DD name. May be dynamic allocation failure. DD name must match SELECT ASSIGN. Case sensitive in some systems.
👁 0
Q: What is PROCEDURE-POINTER?
Answer:
USAGE PROCEDURE-POINTER stores program addresses. SET proc-ptr TO ENTRY 'PROGNAME'. CALL proc-ptr. Enables dynamic program selection. Similar to function pointers. Used in table-driven designs. Check ADDRESS OF for validity.
👁 0
Q: Explain SMS-managed storage
Answer:
SMS (Storage Management Subsystem) manages dataset placement. Specify STORCLAS, MGMTCLAS, DATACLAS in DD. DATACLAS sets DCB attributes, STORCLAS controls placement, MGMTCLAS defines retention. SMS uses ACS routines for assignment.
👁 0
Q: How to use INCLUDE statement?
Answer:
INCLUDE MEMBER=name inserts JCL from JCLLIB member. Processed at conversion time. Can contain any JCL statements. Modular JCL design. INCLUDE can contain INCLUDE. SET statements affect included members.
👁 0
Q: What is CLASS parameter?
Answer:
CLASS assigns job to execution class. CLASS=A on JOB card. Initiators start jobs by class. Determines execution priority, resources. Installations define class characteristics. Multiple classes: CLASS=AB (not common). JES2/JES3 interpret differently.
👁 0
Q: What is ASSIGN command?
Answer:
ASSIGN retrieves system values. EXEC CICS ASSIGN USERID(ws-user) FACILITY(ws-term). Other options: SYSID, ABCODE, PROGRAM. Gets runtime environment info. Useful for audit, conditional processing.
👁 0
Q: What is DFSMS?
Answer:
DFSMS (Data Facility Storage Management Subsystem) automates storage management. Components: SMS, HSM (migration), DFRMM (tape). ACS routines assign classes. Reduces JCL complexity. DATACLAS defines data characteristics.
👁 0
Q: Explain STORCLAS parameter?
Answer:
STORCLAS assigns SMS storage class. STORCLAS=classname. Determines placement, management, backup. ACS routines may assign. Defines performance characteristics. Installation-defined classes.
👁 0
Q: What is MGMTCLAS parameter?
Answer:
MGMTCLAS assigns SMS management class. Controls migration, backup, retention. MGMTCLAS=classname. Defines data lifecycle. HSM uses management class. Installation-defined policies.
👁 0
Q: How to handle CICS security?
Answer:
RACF/ACF2 integration. EXEC CICS QUERY SECURITY. SIGNON establishes identity. VERIFY checks resource access. XFCT/XPPT exits. Secure by default.
👁 0
Q: How to split VSAM file?
Answer:
REPRO with FROMKEY/TOKEY extracts range. Create multiple target clusters. REPRO ranges to each. Or program logic to split. Consider partitioning design.