👁 0
Q: How do I fix S0C7 Data Exception ABEND?
Answer:
S0C7 occurs when the program tries to perform arithmetic on non-numeric data.
Common Causes:
- Uninitialized numeric fields (contains spaces/garbage)
- Moving alphanumeric data to numeric field
- Reading file with wrong record layout
- Array subscript accessing wrong memory
How to Fix:
- Initialize all numeric fields to ZEROS
- Validate input before arithmetic
- Check file layouts match
- Use DISPLAY to debug field contents
* Always initialize
INITIALIZE WS-RECORD.
MOVE ZEROS TO WS-AMOUNT.
* Validate before use
IF WS-INPUT IS NUMERIC
COMPUTE WS-RESULT = WS-INPUT * 2
END-IF.
👁 0
Q: When should I use COMMIT in DB2?
Answer:
COMMIT saves all changes since the last COMMIT and releases locks.
When to COMMIT:
- After processing a logical unit of work
- Periodically in long-running batch (every N records)
- Before ending the program successfully
Frequency Guidelines:
- Too frequent: Performance overhead
- Too rare: Lock contention, large log
- Typical: Every 100-1000 records in batch
Best Practice:
MOVE 0 TO WS-COMMIT-COUNT.
PERFORM PROCESS-RECORD.
ADD 1 TO WS-COMMIT-COUNT.
IF WS-COMMIT-COUNT >= 500
EXEC SQL COMMIT END-EXEC
MOVE 0 TO WS-COMMIT-COUNT
END-IF.
Note: In CICS, syncpoint (COMMIT) happens automatically at task end. Explicit SYNCPOINT is rarely needed.
👁 0
Q: What is pseudo-conversational programming in CICS?
Answer:
Pseudo-conversational programming is a technique where the program ends between user interactions, freeing system resources.
How it works:
- Program sends screen to user and ends (RETURN TRANSID)
- User enters data and presses Enter
- CICS starts a new task with same program
- Program retrieves saved data from COMMAREA
- Process continues
Benefits:
- Efficient resource usage
- Better response times
- More concurrent users
Implementation:
* End task, wait for user
EXEC CICS RETURN
TRANSID('MENU')
COMMAREA(WS-COMM)
LENGTH(100)
END-EXEC.
* On return, check EIBCALEN
IF EIBCALEN = 0
PERFORM FIRST-TIME
ELSE
MOVE DFHCOMMAREA TO WS-COMM
PERFORM PROCESS-INPUT
END-IF.
👁 0
Q: What is the difference between SECTION and PARAGRAPH in COBOL?
Answer:
SECTION:
- Contains one or more paragraphs
- Ends with next SECTION or end of program
- Used for logical grouping
- Can be performed as a unit
PARAGRAPH:
- Basic unit of code
- Named block of statements
- Ends at next paragraph name or SECTION
PERFORM SECTION-NAME executes all paragraphs in the section.
PERFORM PARA-NAME executes only that paragraph.
👁 0
Q: How does SEARCH ALL differ from SEARCH?
Answer:
SEARCH performs a sequential/linear search from the current index position. SEARCH ALL performs a binary search requiring the table to be sorted (ASCENDING/DESCENDING KEY clause) and indexed. SEARCH ALL is faster for large tables but requires sorted data.
👁 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: How to tune DB2 queries?
Answer:
Check EXPLAIN output. Look at: access type (index vs scan), join method, sort operations. Add indexes for predicates. Rewrite with hints. Update statistics. Check for full tablespace scans. Monitor actual execution.
👁 0
Q: Explain SECTION vs PARAGRAPH
Answer:
SECTION groups related paragraphs, terminated by next SECTION or end of program. PARAGRAPH is a named block of code, terminated by next paragraph/section. PERFORM SECTION executes all paragraphs within. SECTION needed for segmentation, PARAGRAPH for simple procedures.
👁 0
Q: What is USAGE clause?
Answer:
USAGE specifies internal data representation. DISPLAY (default)=character, COMP/BINARY=binary, COMP-3/PACKED-DECIMAL=packed, COMP-1=single float, COMP-2=double float. Affects storage size and arithmetic performance.
👁 0
Q: What is MQT?
Answer:
MQT (Materialized Query Table) stores computed results. CREATE TABLE name AS (SELECT...) DATA INITIALLY DEFERRED REFRESH DEFERRED. Improves query performance. REFRESH TABLE updates. Use for aggregations, joins.
👁 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 XML support in DB2?
Answer:
DB2 stores XML natively. XMLTYPE column. XMLPARSE, XMLSERIALIZE for conversion. XQuery for querying. XMLTABLE extracts relational from XML. XML indexes for performance. Powerful for document storage.
👁 0
Q: What is CI and CA in VSAM?
Answer:
CI (Control Interval) is I/O unit, like block. Contains records, free space, control info. CA (Control Area) is group of CIs. CISIZE affects performance. CI split when full. CA split more expensive.
👁 0
Q: How to use EXIT PERFORM?
Answer:
EXIT PERFORM immediately exits current PERFORM loop. EXIT PERFORM CYCLE skips to next iteration. COBOL 2002+ feature. Previously used GO TO with OUT-OF-PARAGRAPH technique. Makes loop control cleaner without extra flags.
👁 0
Q: What is SPANNED record?
Answer:
Spanned records exceed CI size, span multiple CIs. DEFINE CLUSTER ... RECORDSIZE(avg max) SPANNED. CI too small for max record. Performance impact. Use appropriately sized CI when possible.
👁 0
Q: What is PERFORM recursion limit?
Answer:
COBOL doesn't traditionally support recursion; same paragraph in PERFORM stack causes error. RECURSIVE clause in PROGRAM-ID enables it. Recursive programs need local storage. Stack depth limited by system resources. Usually avoid in COBOL.
👁 0
Q: Explain DEBUGGING declarative
Answer:
USE FOR DEBUGGING enables debug procedures. Requires WITH DEBUGGING MODE. Triggers on: ALTER, PERFORM, GO TO, or reference to debug item. Displays data values and flow. Object code excluded unless compiled with DEBUG option.
👁 0
Q: How to use PERFORM EXIT?
Answer:
EXIT statement marks paragraph end. PERFORM PROCESS-DATA THRU PROCESS-EXIT. Process-exit paragraph contains only EXIT. Ensures consistent exit point. Can also GO TO exit paragraph. EXIT PROGRAM in subprogram returns to caller.
👁 0
Q: How to handle binary data?
Answer:
COMP/BINARY stores binary. PIC S9(4) COMP is halfword (2 bytes). PIC S9(9) COMP is fullword (4 bytes). PIC S9(18) COMP is doubleword (8 bytes). SYNC aligns for performance. Value range limited by bytes, not picture.
👁 0
Q: How to improve KSDS performance?
Answer:
Appropriate CISIZE, FREESPACE. Adequate buffers (BUFND/BUFNI). Index in cache if possible. IMBED obsolete. Keep file organized (REORG). Monitor CA/CI splits. Sequential access for bulk.
👁 0
Q: Explain MASSINSERT?
Answer:
MASSINSERT optimizes bulk sequential inserts. System defers CI splits. Better performance for loads. Implicit with REPRO. COBOL can hint with APPLY WRITE-ONLY style.
👁 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 SPANNED records impact?
Answer:
Spanned records span CIs. More I/O for spanned record access. CI header overhead per CI. Avoid if possible by larger CI. Performance degradation for random access.
👁 0
Q: What is PRTY parameter?
Answer:
PRTY sets selection priority. PRTY=15 on JOB card. Values 0-15 (15 highest). Affects when job selected from queue. JES2 processes higher PRTY first within class. Different from PERFORM (execution priority).
👁 0
Q: Explain BUFNO parameter
Answer:
BUFNO sets number of I/O buffers. DCB=(BUFNO=5). More buffers improve sequential performance but use memory. System default often 5. VSAM uses different buffering (BUFNI, BUFND). Too many can waste memory.
👁 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: How does REORG work?
Answer:
REORG physically reorganizes tablespace or index. Eliminates fragmentation, reclaims space, restores clustering. REORG TABLESPACE db.ts. Options: SHRLEVEL (REFERENCE/CHANGE), LOG (YES/NO). Schedule during low activity. Run RUNSTATS after.
👁 0
Q: What is CICS monitoring?
Answer:
CICS monitoring facilities. SMF 110 records. CICS statistics. Transaction analysis. Performance data. OMEGAMON for real-time. Capacity planning.
👁 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: What is maximum VSAM key length?
Answer:
Maximum key length is 255 bytes. KEYS(255 offset). Practical limits lower for performance. Index size grows with key. Keep keys reasonably sized.
👁 0
Q: Explain CREATE INDEX
Answer:
CREATE INDEX creates index on table. CREATE INDEX idx ON table(col1, col2). UNIQUE prevents duplicates. CLUSTER determines physical order. Include columns for index-only access. Drop unused indexes for insert performance.
👁 0
Q: Explain DB2 triggers
Answer:
Trigger fires automatically on INSERT/UPDATE/DELETE. CREATE TRIGGER name AFTER/BEFORE/INSTEAD OF event ON table FOR EACH ROW/STATEMENT. Use for audit, validation, derived columns. Can impact performance.
👁 0
Q: Explain PERFORM VARYING with example
Answer:
PERFORM VARYING executes a paragraph while incrementing a counter. Syntax: PERFORM para-name VARYING WS-IDX FROM 1 BY 1 UNTIL WS-IDX > 10. The counter is initialized, tested, and incremented automatically. Can have nested VARYING with AFTER clause.
👁 0
Q: Explain sequence objects
Answer:
SEQUENCE generates unique numbers. CREATE SEQUENCE name START WITH 1 INCREMENT BY 1. NEXT VALUE FOR sequence-name gets next. Used for keys. Cached for performance. No gaps guaranteed.
👁 0
Q: What is CORRESPONDING in COBOL?
Answer:
CORRESPONDING (CORR) operates on fields with matching names. MOVE CORRESPONDING record-1 TO record-2 moves all matching fields. ADD CORRESPONDING does arithmetic. Reduces code but requires careful naming. Not recommended for performance-critical code.
👁 0
Q: How to monitor DB2 performance?
Answer:
Use OMEGAMON, DB2PM, or built-in monitor. Check: buffer pool hit ratios, lock waits, CPU time, elapsed time. DISPLAY commands show real-time. Statistics trace for analysis. EXPLAIN for query level.
👁 0
Q: What is REBIND and when needed?
Answer:
REBIND updates access path without precompile. REBIND PACKAGE after RUNSTATS, index changes. REBIND PLAN for plan-level changes. Can improve or degrade performance - test first. EXPLAIN before/after.
👁 0
Q: Explain COMPUTE statement
Answer:
COMPUTE performs arithmetic with expression syntax. COMPUTE RESULT = (A + B) * C / D. Supports + - * / ** operators. ROUNDED option rounds result. ON SIZE ERROR handles overflow. Clearer than separate ADD/SUBTRACT/MULTIPLY/DIVIDE for complex formulas.
👁 0
Q: How to define and use indexes?
Answer:
INDEX defined with OCCURS: 05 WS-TABLE OCCURS 10 INDEXED BY WS-IDX. SET WS-IDX TO 5 sets position. SET WS-IDX UP/DOWN BY 1 changes position. Use SEARCH verb with index. More efficient than subscripts for table access.
👁 0
Q: How to work with OCCURS indexed tables?
Answer:
Define: 01 WS-TABLE. 05 WS-ENTRY OCCURS 100 INDEXED BY WS-IDX. 10 WS-NAME PIC X(20). 10 WS-VALUE PIC 9(5). Access: MOVE WS-NAME(WS-IDX) TO output. Search: SEARCH WS-ENTRY WHEN WS-NAME(WS-IDX) = 'VALUE' perform action.
👁 0
Q: What is zparm?
Answer:
ZPARM (DSNZPARMs) are DB2 installation parameters. Control system behavior, limits, defaults. DSNZPARM module loaded at startup. Changes need restart usually. Critical for performance and security tuning.
👁 0
Q: What is SYNCHRONIZED clause?
Answer:
SYNCHRONIZED aligns binary items on natural boundaries for efficient access. 01 WS-GROUP. 05 WS-CHAR PIC X. 05 WS-BINARY PIC S9(8) COMP SYNC. Adds slack bytes as needed. Can waste space but improves performance. RIGHT/LEFT options available.
👁 0
Q: What is ON SIZE ERROR?
Answer:
ON SIZE ERROR traps arithmetic overflow. COMPUTE X = A + B ON SIZE ERROR PERFORM error-handler END-COMPUTE. Also NOT ON SIZE ERROR for success. Must be enabled (TRUNC option). Prevents abends from overflow conditions.
👁 0
Q: Explain BUFND and BUFNI
Answer:
BUFND is data buffer count, BUFNI is index buffer count. More buffers improve performance but use memory. JCL AMP='BUFNI=10,BUFND=20'. Default usually 2. Tune based on access pattern.
👁 0
Q: How does PERFORM THRU work?
Answer:
PERFORM para-1 THRU para-2 executes from para-1 through para-2 inclusive. Paragraphs must be contiguous. Common: PERFORM 1000-INIT THRU 1000-EXIT where EXIT paragraph has only EXIT. Ensures cleanup code always runs.
👁 0
Q: What is APPLY WRITE-ONLY?
Answer:
APPLY WRITE-ONLY FOR file-name optimizes output buffer handling. System doesn't preserve record area after WRITE. Can't re-read just-written record. Improves I/O performance. Use when write-only access pattern is guaranteed.
👁 0
Q: What is BLOCK CONTAINS clause?
Answer:
BLOCK CONTAINS defines blocking factor. BLOCK CONTAINS 10 RECORDS or BLOCK CONTAINS 800 CHARACTERS. 0 RECORDS means system-determined. Affects I/O performance-larger blocks fewer I/Os. Must match JCL/VSAM definition.
👁 0
Q: What is WRITECHECK?
Answer:
WRITECHECK verifies writes by reading back. Extra I/O for verification. Rarely needed with modern hardware. Can slow performance. Default off. Use only if data corruption suspected.
👁 0
Q: What is SERVICE RELOAD?
Answer:
SERVICE RELOAD refreshes segmented program overlays. Forces segment reload from disk. Rarely needed with virtual storage. From overlay management era. May affect performance. Better to restructure program than use frequently.
👁 0
Q: What is ORDERED attribute?
Answer:
ORDERED on DEFINE allocates volumes in specified order. Without ORDERED, system chooses. ORDERED ensures predictable allocation. May be important for performance tuning.
👁 0
Q: Explain DD DUMMY statement
Answer:
DD DUMMY discards output/provides EOF for input. No I/O actually performed. DUMMY, DSN=NULLFILE equivalent. Use to skip optional outputs or provide empty input. Program sees immediate EOF on read. Writes succeed but discarded.
👁 0
Q: How to monitor VSAM performance?
Answer:
SMF records for I/O counts. LISTCAT for statistics (READS, WRITES, SPLITS). RMF reports. Third-party tools. Track CI/CA splits, EXCP counts, buffer hit ratios.
👁 0
Q: What is AMP parameter?
Answer:
AMP specifies VSAM buffer parameters. AMP='BUFNI=8,BUFND=4' for index/data buffers. AMP='AMORG' for VSAM organization. OPTCD for options. Overrides VSAM cluster definitions for this run. Affects performance.
👁 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 EXPLAIN and how to use it?
Answer:
EXPLAIN analyzes query access path. EXPLAIN PLAN SET QUERYNO=1 FOR SELECT... Results in PLAN_TABLE. Shows index usage, join method, sort operations. Use for performance tuning. Review ACCESSTYPE, MATCHCOLS, PREFETCH columns.
👁 0
Q: What is DB2 buffer pool?
Answer:
Buffer pool caches data/index pages in memory. BP0, BP1, etc. Hit ratio critical for performance. GETPAGE vs SYNCIO shows effectiveness. Size appropriately. Virtual buffer pool for each pool. Monitor with statistics.
👁 0
Q: What is FETCH SENSITIVE cursor?
Answer:
SENSITIVE cursor reflects concurrent changes by other processes. EXEC SQL DECLARE cursor SENSITIVE STATIC/DYNAMIC SCROLL CURSOR. INSENSITIVE does not see changes. Affects isolation behavior. Consider performance impact.
👁 0
Q: Explain ORDER BY options
Answer:
ORDER BY sorts results. ORDER BY col1 ASC, col2 DESC. ASC default. NULLS FIRST/LAST controls NULL position. Ordinal: ORDER BY 1, 2 uses column positions. ORDER BY CASE for custom order. Affects performance.