👁 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: How to handle -551 SQLCODE?
Answer:
-551 is authorization failure. No privilege for operation. Check GRANT statements. May need SELECT, UPDATE, DELETE, INSERT authority. GRANT privilege ON object TO user/role. Check SYSIBM.SYSTABAUTH.
👁 0
Q: What is GRANT and REVOKE?
Answer:
GRANT gives privileges: GRANT SELECT ON table TO user. REVOKE removes: REVOKE SELECT ON table FROM user. Privileges: SELECT, INSERT, UPDATE, DELETE, EXECUTE. WITH GRANT OPTION allows re-granting. Essential for security.
👁 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 SQLCODE 100?
Answer:
SQLCODE 100 means not found or end of data. For SELECT INTO: no matching row. For FETCH: no more rows. For UPDATE/DELETE: no rows affected. Check context - may be normal condition, not error.
👁 0
Q: How to delete VSAM cluster?
Answer:
IDCAMS DELETE ds.name CLUSTER. Or DELETE ds.name FILE(ddname) if DD provided. PURGE overrides retention. ERASE clears data. DELETE removes catalog entry and data/index components.
👁 0
Q: Explain REUSE parameter
Answer:
REUSE allows reloading without delete/define. DEFINE CLUSTER ... REUSE. OPEN OUTPUT resets to empty. Like scratch and rewrite. Good for temporary work files. Cannot be UNIQUE.
👁 0
Q: How to reorganize VSAM?
Answer:
REPRO out then back: REPRO to sequential, DELETE cluster, DEFINE new cluster, REPRO back. Alternatively, IDCAMS export/import. Reclaims space, restores free space distribution. Schedule regularly.
👁 0
Q: What is NOSCRATCH?
Answer:
NOSCRATCH on DELETE keeps data space. Entry removed from catalog but space not released. Rarely used. Normal DELETE releases space. May be useful for recovery scenarios.
👁 0
Q: What is ERASE on DELETE?
Answer:
ERASE overwrites data with binary zeros. Physical erase before space release. Security requirement for sensitive data. Takes time. Without ERASE, data remains until overwritten.
👁 0
Q: How to use temporary storage?
Answer:
TS queue stores data across tasks. EXEC CICS WRITEQ TS QUEUE(name) FROM(data). READQ retrieves. DELETEQ removes. ITEM number for multiple items. MAIN/AUXILIARY for storage type. Named by string.
👁 0
Q: What is PATHDISP parameter?
Answer:
PATHDISP=(normal,abnormal) for USS files. Options: KEEP, DELETE. PATHDISP=(KEEP,DELETE). Used with PATH parameter. Similar to DISP for MVS datasets. Controls USS file retention.
👁 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: 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 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: What is OPEN mode options?
Answer:
OPEN INPUT for read, OUTPUT for write (creates), I-O for read/update, EXTEND for append. Multiple files per OPEN. OPEN OUTPUT deletes existing file! EXTEND preserves and adds. File must be closed before reopening in different mode.
👁 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: What is ERASE parameter?
Answer:
ERASE overwrites data on delete. DELETE CLUSTER ERASE. Security feature - data unrecoverable. Without ERASE, space released but data remains. Use for sensitive data.
👁 0
Q: How to recover damaged VSAM?
Answer:
Run VERIFY first. Then REPRO if possible. May need forward/backward recovery from logs. EXAMINE checks for problems. May need DELETE and restore from backup.
👁 0
Q: How does DISP parameter work?
Answer:
DISP=(status,normal-end,abnormal-end). Status: NEW/OLD/SHR/MOD. Normal-end: DELETE/KEEP/PASS/CATLG/UNCATLG. Abnormal-end: same options. Example: DISP=(NEW,CATLG,DELETE) creates new, catalogs if OK, deletes if abend. MOD appends or creates if not exists.
👁 0
Q: How to switch file for restart?
Answer:
IDCAMS DELETE/DEFINE or REUSE attribute. REUSE allows OPEN OUTPUT reset. Alternative: JCL with DISP=(NEW,CATLG,DELETE) pattern. Checkpoints may need restart considerations.
👁 0
Q: How to create temporary VSAM?
Answer:
Use REUSE attribute. Or define/delete in same job. Or use GDG-like naming. JCL doesn't support && for VSAM. IDCAMS DELETE at job end. Cannot be truly temporary like sequential.
👁 0
Q: How to resize VSAM?
Answer:
Cannot resize directly. REPRO out, DELETE, DEFINE larger, REPRO back. Or ALTER to add secondary space/volumes. Planning important - define adequate size initially.
👁 0
Q: How to define temporary dataset?
Answer:
Temporary datasets: DSN=&&TEMP or omit DSN. Exist for job duration only. Not cataloged. Passed between steps with DISP=PASS. Automatically deleted at job end. Example: //WORK DD DSN=&&TEMP,UNIT=SYSDA,SPACE=(CYL,5)
👁 0
Q: What is IEFBR14?
Answer:
IEFBR14 is null program (Branch to Register 14 = return). Returns immediately. Used for dataset management: create, delete, catalog datasets. //DELETE EXEC PGM=IEFBR14 //DD DD DSN=name,DISP=(MOD,DELETE). Common for housekeeping.
👁 0
Q: What is IDCAMS utility?
Answer:
IDCAMS manages VSAM and catalog. Commands: DEFINE CLUSTER, DELETE, REPRO, LISTCAT, ALTER, PRINT. //SYSIN DD * has commands. REPRO copies VSAM files. DEFINE creates VSAM clusters. IF/THEN/ELSE for conditional processing.
👁 0
Q: How does IEFBR14 delete work?
Answer:
//DEL EXEC PGM=IEFBR14 //DD DD DSN=file,DISP=(MOD,DELETE). If file exists, DISP=(MOD,DELETE) deletes. If not exists, MOD creates then deletes (empty). Or DISP=(OLD,DELETE) fails if not exists. Common pattern for cleanup.
👁 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 to handle NOTFND condition?
Answer:
NOTFND means record not found. Check RESP: IF ws-resp = DFHRESP(NOTFND). Or HANDLE CONDITION NOTFND(para). Common for READ/DELETE. Handle gracefully - display message, take action.
👁 0
Q: What is RETPD parameter?
Answer:
RETPD=nnn specifies retention days. Cannot delete until expired. EXPDT=yyddd for specific date. EXPDT=99365 or RETPD=9999 for permanent. Security software may override. Affects tape and disk datasets.
👁 0
Q: Explain EXPDT parameter?
Answer:
EXPDT=yyddd or EXPDT=yyyyddd expiration date. After this date, dataset can be deleted. EXPDT=99365 effectively permanent (1999 or 2099). RETPD alternative. Security software may enforce or override.
👁 0
Q: What is REUSE option purpose?
Answer:
REUSE allows OPEN OUTPUT to reset file. Like delete/define without overhead. Good for work files. DEFINE CLUSTER ... REUSE. Cannot be UNIQUE. Efficient for scratch files.