DB2 Tough Questions (3 of 4)

Read  my 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 SQL Query?

Yes, Select and Insert both can be given simultaneously in a SQL Query

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.