Pages

Ads 468x60px

Sunday, 3 June 2012

PL SQL Program For to find the person whose getting maximum salary using cursor.


PL SQL Program For to find the person whose getting maximum salary using cursor. 


declare
cursor c is select name,job,salary from employee;
empname employee.name%type;
jobs employee.job%type;
sal employee.salary%type;
maxname employee.name%type:=0;
maxjob employee.job%type:=0;
maxsal employee.salary%type:=0;
begin
open c; 
fetch c into empname,jobs,sal;
loop
fetch c into empname,jobs,sal;
if(maxsal maxsal:=sal;
maxjob:=jobs;
maxname:=empname;
end if;
exit when c%notfound;
end loop;
dbms_output.put_line('DETAILS OF THE PERSON GETTING MAXIMUM SALARY');
dbms_output.put_line('EMPLOYEE NAME : '||maxname);
dbms_output.put_line('DESIGNATION : '||maxjob);
dbms_output.put_line('SALARY : '||maxsal);
close c;
end;

0 comments:

Post a Comment

Total Pageviews