👁 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: What is PIC clause editing?
Answer:
Picture editing characters: Z=zero suppress, *=check protect, +=sign, -=negative, CR/DB=credit/debit, $=currency, .=decimal, ,=comma, B=blank. Example: PIC ,ZZ9.99- displays $ 123.45-. Insertion characters add to display.
👁 0
Q: What is the difference between COND and IF/THEN/ELSE?
Answer:
COND tests return codes to skip steps (negative logic - skips IF true). IF/THEN/ELSE tests conditions to execute steps (positive logic). IF supports complex expressions, COND is simpler but confusing. IF preferred for readability. COND on JOB affects all steps; on EXEC affects that step.
👁 0
Q: What is indicator variable?
Answer:
Indicator variable detects NULL values. Declare: 01 col-var. 01 col-ind PIC S9(4) COMP. Use: INTO :col-var:col-ind. If col-ind < 0, value is NULL. Set indicator negative to insert NULL. Required for nullable columns.
👁 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.