In DB2 real time projects, the role of Cursors and JOINS is major part. I have selected some tough questions on Cursors and JOINS. Useful for your job and interviews.
Read my DB2 Tough interview questions-Part:2 if you miss it.
Q1) How to Declare a cursor for multi-row fetch?
EXEC SQL DECLARE C1 CURSOR WITH ROWSET POSITIONING FOR SELECT * FROM EMP;
Q2) How to fetch first X rows?
FETCH FIRST ROWSET FROM C1 FOR x ROWS INTO ...
Q3) How many tables can be joined?
255
Q4) How to Declare host variable array?
01 OUTPUT-VARS. 05 LASTNME-1 OCCURS 10 TIMES. 49 LASTNME-LGTH-1 PIC S9(4) USAGE COMP. 49 LASTNME-DATA-1PIC X(50). 05 EMPNO-1 PIC S9(9) COMP-4 OCCURS 10 TIMES.
Q5) Can we give SELECT and INSERT in a single SQL Query?
Yes, Select and Insert both can be given simultaneously in a single SQL Query
References