Wednesday 21 September 2011

DB2 Interview questions

1. Why do we use 'CURSOR WITH HOLD' option?
A cursor normally gets closed after a 'COMMIT' statement. 'Cursor with hold' is used in order to have the cursor open after 'COMMIT'

2. What is SQLCODE -811? How can this be resolved?
SQLCODE -811 is issued when a SELECT query in the program fetches more than one row. The solution for this error is to use a cursor. By using a cursor, the result of the query can be fetched one by one.

3. What is SQLCODE -803?
-803 is for unique index violation. When we try to insert a duplicate record, sqlcode -803 is issued.

4. What is SQLCODE -818?
When a COBOL-SQL program is built, the precompile timestamp can be found in LOAD and DBRM. When the precompile timestamps in the LOAD and DBRM differs, SQLCODE -818 is issued.

5. Explain Commit-Restart logic?
When Database operations are performed for large number of rows, the changes will be committed on certain frequency. During commit, the key(s) used for the cursor will be stored. When there is a restart of the program, the program will be restarted from the checkpoint rather than the beginning.

This post will be updated regularly. Your contributions to this blog are welcome. Please send the interview questions to knowmainframe@gmail.com

No comments:

Post a Comment