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

Mention data types used in db2 ?

879


What is the usage of open cursor command?

770


Mention the downsides of page level lock.

909


What is the role of data manager in the db2 database?

838


What is the role of schema in the db2 database?

897


Explain about cursor stability?

776


What are the rules for db2 programming?

836


What is bind and rebind in db2?

868


Is it possible using max on a char column?

832


What is the difference between db2 and oracle?

864


How can you validate Sql errors during cursor operation in db2 pgms and where do you code?

1949


What does a deadlock mean in DB2?

837


What is null value in db2?

750


What are the two types of logging in the db2 database? Explain them.

786


What is a bind in db2?

762