Sunday 11 May 2014

DB2 interview questions

Most frequently asked DB2 interview questions:
1.When do you get DB2 sqlcode -811 and how to resolve the issue?
  Read here for complete information on DB2 sqlcode -811 and the resolution

2. When do you get DB2 sqlcode -803 and how to resolve the issue?
  Read here for complete information on DB2 sqlcode -803 and the resolution

3.Some of the differences between DB2 version 9 and DB2 version 10?
 Read here to get know some basic differences on DB2 Version 9 and DB2 version 10

4.How to identify a program whether it has DB2 by looking at the JCL?
   Read here for complete information on finding out a program whether it has DB2 by looking at JCL

5.When a DB2 table is changed,how impact analysis can be done?
    Read here to get to know how impact analysis can be done ,
    Finding impacted programs if a DB2 table is altered

6.Why SELECT* is not preferred in COBOL-DB2 program?
   Read here for complete information on Probeble issues of using SELECT* in a COBOL-DB2 program

DB2 sqlcode -811

DB2 sqlcode -811 is expected when a query returns more than one row .

When DB2 sqlcode -811 is the issue,then
first we should find what are the keys for which 2 rows are returned
then decide what to be done .That is either to delete one row or handle multiple rows in the query(implement cursor logic).

For more understanding on how the issue can be handled,read here DB2 sqlcode -811

DB2 sqlcode -803

DB2 sqlcode -803 is expected when a duplication of an index occurs due to insert or update operation.

When DB2 sqlcode -803 is returned,then we need to understand
Why the sqlcode -803 happened
How to identify which table field is causing -803 sqlcode
How to correct the issue.

To get to know all these things,please read here on
DB2 sqlcode -803


DB2 SQL -How to fetch first few records?

We can use FETCH FIRST n ROWS ONLY, if we want to display only first n rows.This should be the last statement in the SQL query.

To find first 10 rows then we mention it like
FETCH FIRST 10 ROWS ONLY

DB2 current date

CURRENT DATE returns the today's date in DB2.

For more information on DB2 DATE functions,read here on , DB2 DATE functions


DB2 DATE format

DB2 DATE format if we use CURRENT DATE function is
2014-02-26 (YYYY-MM-DD)

For more information on DB2 DATE functions ,read here on
DB2 DATE format and DATE functions example

DB2 Timestamp format

DB2 Timestamp format if we use CURRENT TIMESTAMP function is as below
2014-02-27-09.30.18.294199
YYYY-MM-DD-HH.MM.SS.MS

For more information on DB2 Timestamp,read here on 
DB2 Timestamp example and explanation