Monday, November 5, 2007

code no. 6&7

6.Write a plsql codeto display the first two maximum salaries on screen?
sol:
Declare
cursor c3 is select sal from tab2 order by sal desc;
s tab2.sal% type;
Begin
open c3;
loop
fetch c3 into s;
dbms_output.put_line(s);
exit when c3%rowcount>2;
end loop;
close c3;
end;
/

7.Write a pl/sql code to display first three salaries on the screen?
sol:
Declare
cursor c5 is select sal from tab2;
n tab2.sal%type;
Begin
open c5;
loop
fetch c5 into n;
dbms_output.put_line(n);
exit
when c5%rowcount>2;
end loop;
close c5;
end;
/


Get the freedom to save as many mails as you wish. Click here to know how.

No comments: