👁 0
Q: What is CTE (Common Table Expression)?
Answer:
CTE defines temporary result set. WITH cte_name AS (SELECT...) SELECT * FROM cte_name. Improves readability. Can be recursive for hierarchies. Multiple CTEs comma-separated. Referenced in main query. Scope is single statement.
👁 0
Q: Explain REDEFINES clause with an example.
Answer:
REDEFINES allows the same storage area to be referenced by different data names with different definitions.
Rules:
- Must be at same level as item being redefined
- Cannot redefine item with OCCURS
- Redefined item must appear first
- Lengths should match or redefining should be shorter
01 WS-DATE. 05 WS-DATE-NUM PIC 9(8). 01 WS-DATE-X REDEFINES WS-DATE. 05 WS-YEAR PIC 9(4). 05 WS-MONTH PIC 9(2). 05 WS-DAY PIC 9(2).
Same 8 bytes can be accessed as single number or individual components.
👁 0
Q: How to create image copy?
Answer:
COPY utility creates backup. COPY TABLESPACE db.ts. FULL or INCREMENTAL. SHRLEVEL REFERENCE or CHANGE. Store in GDG for versions. Regular copies essential for recovery. COPYTOCOPY duplicates copies.
👁 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 PROCEDURE DIVISION USING
Answer:
PROCEDURE DIVISION USING defines parameters for called program. Parameters match LINKAGE SECTION definitions. Order matches calling program's USING clause. Establishes addressability to passed data. BY REFERENCE/VALUE/CONTENT options inherited from CALL.
👁 0
Q: What is GLOBAL clause?
Answer:
GLOBAL makes data available to nested programs. 01 WS-COUNTER PIC 9(5) GLOBAL. Nested programs can reference without passing as parameters. Use sparingly; explicit passing preferred. File definitions can also be GLOBAL.
👁 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 FUNCTION CURRENT-DATE?
Answer:
FUNCTION CURRENT-DATE returns 21-char timestamp. Format: YYYYMMDDHHMMSSDHHMM (D=hundredths, HH=GMT offset). MOVE FUNCTION CURRENT-DATE TO WS-TIMESTAMP. Parse components with reference modification or REDEFINES.
👁 0
Q: How to pass data between steps?
Answer:
Use DISP=PASS to pass datasets. Receiving step references same DSN. Or use symbolic parameters. GDG allows relative references (+1 created, 0 passed). Temporary datasets (&& prefix) auto-pass. SYSIN instream data copied to subsequent steps.
👁 0
Q: How to define GDG in JCL?
Answer:
Create GDG base with IDCAMS DEFINE GDG. Reference generations: DSN=MY.GDG(+1) for new, DSN=MY.GDG(0) for current, DSN=MY.GDG(-1) for previous. DISP=(NEW,CATLG) for +1. Model DSCB needed for SMS-managed datasets.
👁 0
Q: How to handle VSAM in batch?
Answer:
Define cluster with IDCAMS. JCL DD statement references cluster. COBOL SELECT maps to DD. ACCESS MODE matches operations. Close properly. STATUS check after operations.
👁 0
Q: What is symbolic parameter?
Answer:
Symbols are variables: SET symbol=value or &symbol on JOB/PROC. Reference: DSN=&HLQ..DATA. Resolved at job entry. EXEC proc,symbol=value overrides. SET statement defines. Symbols start with & and up to 8 characters.
👁 0
Q: How does OUTPUT statement work?
Answer:
OUTPUT defines SYSOUT processing options. //OUT1 OUTPUT CLASS=A,DEST=LOCAL,COPIES=2. Reference: //SYSOUT DD SYSOUT=*,OUTPUT=*.OUT1. Centralizes output attributes. Can specify JESDS for JES-level control. Forms, burst options available.
👁 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: Explain generation data groups
Answer:
GDG maintains versions. Base defined with IDCAMS: DEFINE GDG NAME(base) LIMIT(10) SCRATCH. Reference: base(+1) new, base(0) current, base(-1) previous. LIMIT controls kept generations. NOEMPTY/EMPTY for empty condition.
👁 0
Q: How to define VSAM in JCL?
Answer:
//DD DD DSN=VSAM.CLUSTER,DISP=SHR for existing. New cluster needs IDCAMS DEFINE CLUSTER. JCL references cluster, not data/index. AMP parameter for VSAM options: AMP=(BUFNI=8,BUFND=4). Cannot create VSAM with JCL alone.
👁 0
Q: How to reference PDS member?
Answer:
DSN=PDS.NAME(MEMBER). Direct member reference. DISP must allow access. For input, member must exist. For output, overwrites or creates. IEBCOPY for multiple members. Member name 1-8 characters.
👁 0
Q: Explain REFDD parameter?
Answer:
REFDD references DD for attributes. DCB=*.STEP.DD or REFDD=ddname. Copies DCB info. Similar to VOL=REF. Useful for consistent attributes. Referenced DD must be allocated first.
👁 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 ALIAS?
Answer:
ALIAS is alternate name for table. CREATE ALIAS alias FOR table. Useful for cross-subsystem access. Synonym is similar. PUBLIC alias visible to all. ALIAS can point to table in different schema.
👁 0
Q: Explain CALL statement and parameters
Answer:
CALL invokes subprogram: CALL 'SUBPROG' USING param-1 param-2. BY REFERENCE (default) passes address. BY CONTENT passes copy. BY VALUE passes value (for C). ON EXCEPTION handles load failures. CANCEL releases memory.
👁 0
Q: What is reference modification?
Answer:
Reference modification extracts substring: WS-FIELD(start:length). WS-NAME(1:3) gets first 3 characters. Can use in MOVE, IF, DISPLAY. Start position is 1-based. Length optional (to end). More flexible than REDEFINES for variable positions.
👁 0
Q: What is POINTER data type?
Answer:
USAGE POINTER stores memory addresses. SET ptr TO ADDRESS OF data. Used with SET ADDRESS OF linkage-item TO ptr. CALL with BY REFERENCE returns addresses. Supports dynamic memory and chained structures.
👁 0
Q: How to define group level items?
Answer:
Group items contain subordinate items. 01 WS-DATE. 05 WS-YEAR PIC 9(4). 05 WS-MONTH PIC 99. 05 WS-DAY PIC 99. Group is alphanumeric regardless of contents. MOVE WS-DATE moves all 8 bytes. Reference individual or group.
👁 0
Q: What is TALLY special register?
Answer:
TALLY is predefined counter for EXAMINE (obsolete verb). Some code still references it. INSPECT replaced EXAMINE. Not recommended for new code. TALLY is global, can conflict. Define your own counters instead.
👁 0
Q: Explain referback DD
Answer:
Referback references earlier DD: DSN=*.STEP1.DDNAME or DSN=*.DDNAME (same step). Copies DSN and DISP. Can override other parameters. VOL=REF=*.STEP1.DD copies volume. Useful for chained processing.
👁 0
Q: What is CNTL statement?
Answer:
CNTL groups control statements. //name CNTL establishes scope. //name ENDCNTL ends it. Used with OUTPUT or other complex statements. Provides modularity. Can be referenced by name from multiple DDs.
👁 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 use MODIFY parameter?
Answer:
MODIFY references FCB image. MODIFY=(fcb,trc) on OUTPUT. FCB controls forms. TRC is table reference character. For print formatting. Installation-defined FCBs. Used with special forms.