PL/SQL Cursor to Display Records in Odd Numbers

PL/SQL Cursor to Display Records in Odd Numbers:


declare
cursor sodd is select * from student;
cnt number;
rcnt number;
begin
cnt:=1;
rcnt:=1;
for i in sodd
loop
if(cnt=rcnt) then
dbms_output.put_line(i.id||' '||i.name||' '||i.city||' '||i.salary);
cnt:=cnt+2;
end if;
rcnt:=rcnt+1;
end loop;
end;

OUTPUT:

1 Bray Canada 12054
3 Suzan HongKong 5000000
5 Rey Los Angeles 400000



Leave a Reply

Your email address will not be published. Required fields are marked *

7 − 1 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.