DB2 ⭐ Featured
👁 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:

0Successful execution
100No data found / End of cursor
-803Duplicate key on insert
-811Multiple rows returned for singleton SELECT
-904Unavailable resource
-911Deadlock/timeout
-922Authorization failure
-927DB2 not available

Negative = Error, 0 = Success, 100 = No data

COBOL ⭐ Featured
👁 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.
DB2
👁 0

Q: What is SQLCA structure?

Answer:
SQLCA (SQL Communication Area) contains execution results. SQLCODE for return code. SQLERRM for message. SQLERRD(3) for rows affected. SQLWARN for warnings. INCLUDE SQLCA in WORKING-STORAGE. Check after each SQL statement.