how to fetch multiple records without using cursor

Answer Posted / m4io

it is not possible in db2 v8 : you still need a cursor.
However : you can fetch 100 rows in one fetch.

01 host-variables.
05 HV-col1-ARRAY PIC s9(04) COMP OCCURS 100 TIMES.
05 HV-col2-ARRAY PIC x(40) OCCURS 100 TIMES.
05 HV-vcol3-ARRAY OCCURS 100 TIMES.
49 HV-vcol3-len-ARRAY PIC s9(04) COMP.
49 HV-vcol3-txt-ARRAY PIC x(40).
05 HV-IND2-ARRAY PIC s9(04) COMP OCCURS 100 TIMES.
I

DECLARE csr1 CURSOR WITH ROWSET POSITIONING for select
col1, col2, vcol3 from ...

open cursor

FETCH NEXT ROWSET FROM csr1 FOR 100 ROWS
INTO :HV-col1-ARRAY,
:HV-col2-ARRAY:HV-IND2-Array,
:HV-vcol3-ARRAY

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the sqlcode -501

11230


How to take backup of table in db2?

588


What does reorg do in db2?

567


What is dbrm? What it contains?

661


My sql statement select avg(salary) from emp yields inaccurate results. Why?

632






What is the maximum number of columns in a db2 table?

706


What is the maximum size of a char data type in db2?

578


When reorg is used?

661


What is the syntax for FETCH in DB2 ?

655


How can we read records for specific member in CL? AND rpg?

222


What is dclgen (declaration generator)?

592


Mention the different locking levels that are available in db2.

629


Which component is used to execute the sql statements?

609


How to find the number of rows in a db2 table?

638


What is the difference between "db2ilist" and "db2 get instance" commands in DB2 Database Server?

696