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 can you validate Sql errors during cursor operation in db2 pgms and where do you code?

1709


How many databases can be created inside an instance in db2 ?

599


How is deadlock resolved?

650


How to run db2 command in windows?

651


What is a system catalog table in db2?

588






Define check constraint.

644


How do I delete a table in database?

599


Who uses db2?

576


What are db2 objects?

641


What are union and union all?

539


What is a collection in db2?

582


what is the role of the cursor in db2?

643


When the like statement is used?

640


What is node in db2?

608


How can tablespace be moved to another dasd volume that is allocated for that tablespace?

749