how to fetch multiple records without using cursor

Answers were Sorted based on User's Feedback



how to fetch multiple records without using cursor..

Answer / 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

how to fetch multiple records without using cursor..

Answer / rajni

U cant fatch the record without using cursor.

Is This Answer Correct ?    6 Yes 4 No

how to fetch multiple records without using cursor..

Answer / shailendra

its not possible.

Is This Answer Correct ?    3 Yes 3 No

how to fetch multiple records without using cursor..

Answer / om yaddav

hi srini......
how can do in DB@...
?
write with sentax with example.
thans

Is This Answer Correct ?    0 Yes 0 No

how to fetch multiple records without using cursor..

Answer / rookie

#6
I think that answer #6 is definately a food for thought.
Logically speaking that's definately possible, but can
anyone verify it practically:-)
I think it should work....nothing wrong in logic.

Is This Answer Correct ?    0 Yes 0 No

how to fetch multiple records without using cursor..

Answer / premil

It can be done with the help of dynamic sql queries
(prepare,execute).
but i dont remember the syntax...
sorry ...

Is This Answer Correct ?    0 Yes 0 No

how to fetch multiple records without using cursor..

Answer / mahyn

However if we want to fetch and process multiple rows
without using cursor, we can do with the below psuedo code.

assume that seq_num is unique.
h-seq initilized with spaces.

perform until sqlcode = +100 or h-seq >= 500
exec sql
select seq_num into :seq-num from tablename
where seq_num > :h-seq
order by Seq_num with ur;
fetch first 1 row only
end-exec
operations
move seq-num to h-seq
end-perform

Is This Answer Correct ?    0 Yes 0 No

how to fetch multiple records without using cursor..

Answer / chakradhar patra

Yes its possible in NATURAL using MULTI-FETCH Option.

Is This Answer Correct ?    0 Yes 0 No

how to fetch multiple records without using cursor..

Answer / ram g

if u r talking about host language app pgm its not
posssible dats d reason we are hving cursor logic...
in select stmt its quite possible by having condtn in whr
clause such a way it can fetch multiple record..

Is This Answer Correct ?    3 Yes 4 No

how to fetch multiple records without using cursor..

Answer / sivakumar sekharannair

None of the host languages can handle multiple records at a
time.
But i think if we know the number of rows that will be
retreived then we can load the records into a internal
table and then process it as required...
Any thoughts!!!!!!

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More DB2 Interview Questions

if there is a table with huge number of records and if i want to extract only first 3 records from the table, what query i have to provide to retreive first 3 records

4 Answers   UST,


What is the maximum length of sqlca?

0 Answers  


i have cobol+ db2 program but it contains n number of subprograms for this how many dbrm members i need to mention in bind process

2 Answers  


How do I change the column size in db2?

0 Answers  


Is it Possible to declare or create a cursor for UPDATE of table? If yes tell me how? If no Tell me why?

1 Answers   IBM, scintel,






What is the difference between dbm cfg and db cfg file in db2 ?

0 Answers   MCN Solutions,


What is db2 look?

0 Answers  


Where could you look if you had a question about whether a column has been defined as an index?

2 Answers  


I have some 3 particular fields ..i want to know which all tables have those 3 fields. Is there any way to identify.. can we know by quering system tables..

5 Answers   CTS,


What information is held in SYSIBM.SYSCOPY?

1 Answers  


How we create a tables in DB2 ?Previously client has using 7 letters for user id,now he wants to increase the letters from 7 to 12 for user id.How we can do it?

6 Answers   Wipro,


How do I connect my db2 database to ibm?

0 Answers  


Categories