COBOL ⭐ Featured
👁 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
VSAM ⭐ Featured
👁 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

DB2 ⭐ Featured
👁 0

Q: How to handle large objects (LOB)?

Answer:
BLOB/CLOB/DBCLOB for large data. Stored in auxiliary tablespace. Use LOB locators for efficiency. FETCH with INTO :lobvar. INSERT with CLOB(text). LOG NO for LOB tablespace optional.
DB2
👁 0

Q: What is stored procedure?

Answer:
Stored procedure is saved SQL code. CREATE PROCEDURE name(params) BEGIN SQL statements END. CALL name(values) executes. Can have IN/OUT/INOUT parameters. Reduces network traffic. Logic in database. Security benefits.
COBOL
👁 0

Q: What is NATIVE-BCD?

Answer:
NATIVE-BCD is native binary-coded decimal, digits stored one per byte. Less efficient than COMP-3 but simpler to inspect in dumps. Some shops prefer for debugging. Available through compiler options or USAGE clause variations.
COBOL
👁 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.