👁 0
Q: What is the difference between KSDS and ESDS?
Answer:
KSDS (Key Sequenced Data Set):
- Records accessed by unique key
- Records stored in key sequence
- Has both data and index components
- Supports random and sequential access
- Can delete and reinsert records
- Most commonly used VSAM type
ESDS (Entry Sequenced Data Set):
- Records stored in arrival order
- Accessed by RBA (Relative Byte Address)
- No index component
- Cannot delete records (only mark inactive)
- Similar to sequential files
- Good for logs, audit trails
Use KSDS when: You need key-based access, updates, deletes
Use ESDS when: Sequential processing only, append-only data
👁 0
Q: What is SQLCODE and what are common values?
Answer:
SQLCODE is a return code in SQLCA indicating the result of SQL execution.
Common SQLCODE values:
| 0 | Successful execution |
| 100 | No data found / End of cursor |
| -803 | Duplicate key on insert |
| -811 | Multiple rows returned for singleton SELECT |
| -904 | Unavailable resource |
| -911 | Deadlock/timeout |
| -922 | Authorization failure |
| -927 | DB2 not available |
Negative = Error, 0 = Success, 100 = No data
👁 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: What is identity column?
Answer:
Identity column auto-generates values. col INTEGER GENERATED ALWAYS AS IDENTITY. Or GENERATED BY DEFAULT (allows override). Start, increment configurable. Alternative to sequence for single-table keys.
👁 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: Explain START statement for VSAM
Answer:
START positions for sequential READ. START filename KEY IS EQUAL/GREATER/NOT LESS THAN key-field. After successful START, READ NEXT retrieves records sequentially from that position. INVALID KEY handles not-found condition.
👁 0
Q: What is ORGANIZATION clause?
Answer:
ORGANIZATION specifies file structure: SEQUENTIAL (default), INDEXED (VSAM KSDS), RELATIVE (RRDS). Determines access methods available. INDEXED requires RECORD KEY. ACCESS MODE can be SEQUENTIAL, RANDOM, or DYNAMIC.
👁 0
Q: How to define KSDS cluster?
Answer:
IDCAMS DEFINE CLUSTER(NAME(ds.name) INDEXED KEYS(len offset) RECORDSIZE(avg max) SHAREOPTIONS(2 3)) DATA(NAME(ds.data) CYLINDERS(5 1)) INDEX(NAME(ds.index) CYLINDERS(1 1)). Keys required for INDEXED.
👁 0
Q: What is alternate index?
Answer:
AIX provides secondary access path. DEFINE AIX over base cluster. Different key. DEFINE PATH to access. BLDINDEX populates. UPGRADE option maintains AIX on base updates. Multiple AIX per cluster.
👁 0
Q: How to handle file status 23?
Answer:
Status 23 is record not found for random READ or START. Key doesn't exist. Check key value, spelling. May be legitimate (check if exists logic). START with EQUAL, GTEQ, LTEQ options.
👁 0
Q: Explain EXEC SQL statements
Answer:
EXEC SQL marks embedded DB2 SQL. EXEC SQL SELECT col INTO :host-var FROM table WHERE key = :key-var END-EXEC. Colon prefix for host variables. SQLCODE in SQLCA indicates result. Precompiler converts to COBOL calls.
👁 0
Q: How to handle file status 22?
Answer:
Status 22 is duplicate key on WRITE or REWRITE attempt. KSDS primary key must be unique. Check program logic. May indicate data error. Use DUPLICATES option on AIX only if needed.
👁 0
Q: What is KSDS key format?
Answer:
Keys defined by KEYS(length offset). Offset is 0-based. Key extracted from record at offset for length bytes. Alphanumeric comparison. Numeric keys need proper format. Key must be contiguous.
👁 0
Q: What is RBA?
Answer:
RBA (Relative Byte Address) is byte offset from dataset start. ESDS uses RBA for access. KSDS index points to RBA. Changed by REORG. Use key for KSDS, RBA only when necessary.
👁 0
Q: How to access RRDS?
Answer:
ACCESS MODE IS RANDOM. Use RELATIVE KEY for slot number. READ/WRITE by slot. STATUS 23 if slot empty. Can have empty slots. Record size fixed for RRDS.
👁 0
Q: What is EXEC CICS structure?
Answer:
EXEC CICS marks CICS commands. EXEC CICS READ FILE('name') INTO(area) RIDFLD(key) END-EXEC. Commands: READ, WRITE, SEND, RECEIVE, LINK, XCTL. RESP and RESP2 capture return codes. Translator converts to CALL.
👁 0
Q: How to update KSDS record?
Answer:
READ record (optionally FOR UPDATE). Modify record area. REWRITE record. Key cannot change on REWRITE. Status 00 if successful. ACCESS MODE must allow updates.
👁 0
Q: How to handle variable length KSDS?
Answer:
Define with RECORDSIZE(avg max). Read/write variable length records. COBOL RECORD VARYING clause. Key position fixed. Read returns actual length. Write length implicit from record.
👁 0
Q: What is KEYRANGES?
Answer:
KEYRANGES distributes KSDS across volumes by key value. KEYRANGES((low1 high1) (low2 high2)). Each range on different volume. Improves parallel access. Rarely used now.
👁 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: How to load VSAM from sequential?
Answer:
REPRO INFILE(seqfile) OUTFILE(vsamfile). REPLACE option to overwrite existing. Records must match VSAM format. For KSDS, records must be sorted by key. IDCAMS job.
👁 0
Q: Explain NONUNIQUEKEY?
Answer:
AIX can have NONUNIQUEKEY (duplicates). Base cluster KSDS always unique primary key. NONUNIQUEKEY AIX returns first match, use READ NEXT for others. UNIQUEKEY if one-to-one.
👁 0
Q: Explain UPGRADE path AIX?
Answer:
UPGRADE AIX maintained automatically on base cluster changes. PATH allows access but not update. PATH with UPDATE allows updates via alternate key. UPGRADE adds overhead but keeps AIX current.
👁 0
Q: What is EXEC CICS READ?
Answer:
READ retrieves VSAM record. EXEC CICS READ FILE(name) INTO(area) RIDFLD(key) LENGTH(len). Optionally: UPDATE for update intent, KEYLENGTH for partial key. Generic key with GENERIC/KEYLENGTH. Returns NOTFND if missing.
👁 0
Q: What is EIB?
Answer:
EIB (Execute Interface Block) contains execution info. EIBCALEN=COMMAREA length. EIBTRNID=transaction. EIBAID=attention key. EIBDATE/EIBTIME=date/time. EIBRESP/EIBRESP2=response codes. Automatically available in COBOL.
👁 0
Q: How to do file BROWSE?
Answer:
BROWSE reads sequentially. EXEC CICS STARTBR FILE(name) RIDFLD(key). READNEXT/READPREV in loop. ENDBR ends browse. TOKEN for concurrent browses. Can use generic key to position.
👁 0
Q: What is WRITE command?
Answer:
WRITE adds new record. EXEC CICS WRITE FILE(name) FROM(data) RIDFLD(key) LENGTH(len). DUPREC condition if key exists. KEYLENGTH for generic. MASSINSERT optimizes bulk loads.
👁 0
Q: What causes JCL ERROR?
Answer:
JCL ERROR means syntax error or invalid combination. Check: missing commas, unmatched quotes/parentheses, misspelled keywords, invalid parameter values. JES message indicates line and error. JESYSMSG has details.
👁 0
Q: Explain EIBRESP values
Answer:
EIBRESP holds response code. 0=NORMAL. Non-zero indicates condition. Use DFHRESP(condition) for comparison. Common: DFHRESP(NOTFND), DFHRESP(DUPKEY), DFHRESP(INVREQ). Check documentation.
👁 0
Q: What is KEYLENGTH option?
Answer:
KEYLENGTH specifies key portion for generic access. EXEC CICS READ FILE RIDFLD(partial) KEYLENGTH(4) GENERIC. Finds first matching prefix. Use with GTEQ for range.
👁 0
Q: How to handle DUPKEY?
Answer:
DUPKEY on WRITE means key exists. Check: IF ws-resp = DFHRESP(DUPKEY). Handle appropriately - maybe update instead. Or error to user. Common for insert logic.
👁 0
Q: Explain NULLFILE keyword?
Answer:
NULLFILE is alternate for DUMMY. //DD DD NULLFILE. Discards output, provides EOF for input. DSN=NULLFILE equivalent. No actual dataset. Useful for testing without actual files.
👁 0
Q: How to check EIBAID?
Answer:
EIBAID shows attention key pressed. Compare with DFHENTER, DFHPF1-24, DFHCLEAR, DFHPA1-3. Example: IF EIBAID = DFHPF3 do-exit. Determines user action on screen.
👁 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: What is EXEC CICS SEND CONTROL?
Answer:
SEND CONTROL sends control functions. EXEC CICS SEND CONTROL ERASE FREEKB. Clears screen, unlocks keyboard. No map or data. Prepare terminal for next operation.
👁 0
Q: What is clustered index?
Answer:
Clustered index determines physical row order. Only one per table. Other indexes are secondary. CLUSTER keyword on CREATE INDEX. Good for range queries on cluster key. REORG restores clustering after updates.
👁 0
Q: Explain UPDATE with JOIN
Answer:
UPDATE table SET col = value FROM table t1 INNER JOIN table t2 ON... WHERE condition. Or: UPDATE t1 SET col = (SELECT col FROM t2 WHERE t2.key = t1.key). Merge statement is alternative.
👁 0
Q: How to delete with JOIN?
Answer:
DELETE FROM table WHERE key IN (SELECT key FROM other WHERE condition). Or: DELETE FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t1.key = t2.key). Correlated subquery common for conditional delete.
👁 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: Explain partitioning strategies
Answer:
Range partitioning by value ranges (date, key ranges). Hash partitioning distributes evenly. Partition independence allows parallel operations. Partition pruning improves queries. Rotate partitions for time-series.
👁 0
Q: What is FILE STATUS and common codes?
Answer:
FILE STATUS is a 2-byte field capturing I/O operation results. 00=success, 10=end-of-file, 22=duplicate key, 23=record not found, 35=file not found, 39=file attribute mismatch, 41=file already open, 47=not opened input. Essential for error handling.
👁 0
Q: What is SORT and MERGE in COBOL?
Answer:
SORT orders records: SORT SORT-FILE ON ASCENDING KEY-FIELD USING INPUT-FILE GIVING OUTPUT-FILE. INPUT/OUTPUT PROCEDURE allows processing during sort. MERGE combines pre-sorted files: MERGE SORT-FILE ON KEY USING FILE-1 FILE-2 GIVING OUTPUT-FILE.
👁 0
Q: Explain ALTERNATE RECORD KEY
Answer:
ALTERNATE RECORD KEY defines secondary indexes for INDEXED files. SELECT file-name ALTERNATE RECORD KEY IS ALT-KEY WITH DUPLICATES. Allows access by multiple keys. DUPLICATES permits non-unique values. Define path in VSAM cluster.
👁 0
Q: What is REPRO utility?
Answer:
REPRO copies VSAM files. IDCAMS REPRO INFILE(in) OUTFILE(out). Can REPRO between VSAM and sequential. Options: FROMKEY/TOKEY, SKIP/COUNT, REPLACE. Used for backup, conversion, extraction.
👁 0
Q: How to define table with KEY?
Answer:
For binary search, tables need KEY: 05 WS-TABLE OCCURS 100 ASCENDING KEY WS-CODE INDEXED BY WS-IDX. 10 WS-CODE PIC X(5). 10 WS-DESC PIC X(20). SEARCH ALL requires sorted data per KEY. Multiple keys for complex sorts.
👁 0
Q: How to read VSAM sequentially?
Answer:
OPEN INPUT file. START if positioning needed. READ NEXT repeatedly until status 10 (end of file). CLOSE file. START optional - defaults to beginning. READ NEXT gets records in key sequence for KSDS.
👁 0
Q: How to write VSAM random?
Answer:
ACCESS MODE IS RANDOM or DYNAMIC. WRITE record writes at key position. For KSDS, key must not exist (status 22). For ESDS, writes at end. RANDOM/DYNAMIC MODE required.
👁 0
Q: How to delete records from KSDS?
Answer:
READ record with key. DELETE record-name. Status 00 if successful. In COBOL, DELETE uses primary key. Can delete current record after READ. Cannot delete from ESDS.
👁 0
Q: Explain IDCAMS PRINT utility
Answer:
PRINT displays VSAM contents. PRINT INFILE(dd) CHARACTER/HEX/DUMP. FROMKEY/TOKEY limits range. COUNT limits records. Useful for debugging, verification. Output to SYSPRINT.
👁 0
Q: How to access AIX?
Answer:
Open PATH to AIX, not base cluster. READ via alternate key. Can browse by alternate key sequence. Updates depend on PATH UPDATE option. Non-unique AIX returns first, then READ NEXT for others.
👁 0
Q: How to define OCCURS ASCENDING?
Answer:
05 TABLE OCCURS 100 ASCENDING KEY IS CODE-FIELD INDEXED BY IDX. 10 CODE-FIELD PIC X(5). 10 DATA-FIELD PIC X(20). ASCENDING means lower values first. Required for SEARCH ALL. DESCENDING also available. Key must be within occurrence.
👁 0
Q: Explain JSON GENERATE
Answer:
JSON GENERATE creates JSON from data. JSON GENERATE output FROM data-item. NAME clause for custom keys. SUPPRESS clause omits fields. COUNT IN length. COBOL V6+ feature. Generates name-value pairs from structure.
👁 0
Q: How to define ESDS?
Answer:
DEFINE CLUSTER(NAME(ds.name) NONINDEXED RECORDSIZE(avg max)) DATA(NAME(ds.data) CYLINDERS(10 2)). NONINDEXED means ESDS. No KEYS or INDEX components. Access by RBA only.
👁 0
Q: How to SEND MAP to terminal?
Answer:
EXEC CICS SEND MAP(mapname) MAPSET(mapsetname) FROM(symbolic-map) ERASE. CURSOR option positions cursor. FREEKB unlocks keyboard. ALARM sounds alarm. MAPONLY sends without data. DATAONLY sends only modified fields.
👁 0
Q: What is RECEIVE MAP?
Answer:
EXEC CICS RECEIVE MAP(name) MAPSET(mapset) INTO(symbolic-map). Gets terminal input. Modified fields only (MDT). Check EIBAID for key pressed. MAPFAIL if no data. Symbolic map populated with input.
👁 0
Q: Explain REWRITE command
Answer:
REWRITE updates record. Must READ with UPDATE first. EXEC CICS REWRITE FILE(name) FROM(data) LENGTH(len). Changes record held from READ. Cannot change key. TOKEN matches UPDATE-READ.
👁 0
Q: What is DELETE command?
Answer:
DELETE removes record. EXEC CICS DELETE FILE(name) RIDFLD(key). Or after READ UPDATE: DELETE FILE(name). KEYLENGTH/GENERIC for range delete. NOTFND if key missing. NUMREC returns count deleted.
👁 0
Q: How does MERGE work?
Answer:
DFSORT MERGE combines pre-sorted files. SORTIN01, SORTIN02, etc. inputs. MERGE FIELDS=(1,10,CH,A). Files must be sorted on merge key. Output one sorted file. Preserves input order for equal keys.
👁 0
Q: What is KEYLEN parameter?
Answer:
KEYLEN specifies key length for new dataset. DCB parameter for VSAM-like. Or VSAM DEFINE CLUSTER KEYS(length offset). Length 1-255. Required for indexed organization. Offset from 0 or 1 depending on context.
👁 0
Q: Explain RRN in CICS
Answer:
RRN (Relative Record Number) for RRDS files. RIDFLD contains RRN, not key. Numeric 1-based slot number. RRN option on file commands. Access by position not content.
👁 0
Q: Explain DEFINE PATH for VSAM?
Answer:
PATH provides alternate access to VSAM cluster via alternate index. IDCAMS: DEFINE PATH NAME(path.name) PATHENTRY(aix.name). Reference PATH in JCL, not AIX directly. Allows secondary key access.
👁 0
Q: How to handle -803 SQLCODE?
Answer:
-803 is duplicate key violation. Primary key or unique index constraint. Check SQLERRD(3) for index ID. Solutions: check data, use IGNORE_DUPLICATE, handle in program logic. May indicate data quality issue.
👁 0
Q: What is DEFINE ALTERNATEINDEX syntax?
Answer:
DEFINE AIX(NAME(aix.name) RELATE(base.cluster) KEYS(len offset)) DATA(NAME(aix.data)) INDEX(NAME(aix.index)). UNIQUEKEY or NONUNIQUEKEY. UPGRADE to maintain automatically. Must DEFINE PATH and BLDINDEX after.
👁 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.