I have a table which has thousand of records i want to
fetch only record num 100 to record num 200. Write a query
that satisfies this criteria.(Cant use any keys)
Anyone please reply ASAP!

Answer Posted / sudheer d

YA THE ANSWER IS BY USING CURSORS ONLY
declare
cursor USER_Cursor
is select *
from <table_name>;

y <TABLE_NAME>%ROWTYPE; --ITS A DATA TYPE INCLUDES
WHOLE ROW 4M A TABLE IN TO X
COUNT1 number(2);

begin
COUNT1:=1;
open USER_Cursor;

while USER_Cursor%FOUND AND COUNT1 <>101
loop
fetch USER_Cursor into y;-- JUST FETCH DONT DISPLY -
--TILL 101ST RECORD
COUNT1:=COUNT1+1;
end loop;

--NOW DISPLAY FROM 101 RECORD TO 200 RECORD
while USER_Cursor%FOUND AND COUNT1 <>201
loop
fetch USER_Cursor into y;
dbms_output.put_line(y);
COUNT1:=COUNT1+1;
end loop;

close USER_Cursor;
end;

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I add a column in db2?

591


Mention data types used in db2 ?

677


in my project..TEST is db2 8.1 version In PROD it is 7.1 if i do REORG in TEST.. can I use the same REORG jcl with out modification in PROD region (this is DB2 8.1 )? if not, what modification i need to do in my REORG control card?

1626


What is ibm db2 connect?

573


What is db2 command?

584






What is host variable in db2 cobol?

603


Is db2 a programming language?

606


What is declare cursor?

613


What is the use of dclgen in db2?

588


How many types of page locks can be held in db2?

589


How to find the number of rows in db2 tables?

617


What is runstats and reorg in db2?

796


What is dbrm in db2 database?

587


What is cursor stability in db2?

811


Is the primary key a clustered index?

609