Tuesday, 8 March 2011

start demo

This is my first blogging site.Wait and see my post!!!
first program:
4.WRITE
A PL
/SQL CODE BLOCKTHAT WILL DISPLAY THE SALESMAN NO.NAME,SALARY AMOUNT OF THE FIRST 5 SALESMEN GETTING THE HIGHEST SALARY.



SQL> declare
  2  cursor s_det is select * from salesman32 where salary=(select max(salary) from salesman32);
  3  v_no salesman32.s_no%type;
  4  v_name salesman32.s_name%type;
  5  v_salary salesman32.salary%type;
  6  begin
  7  open s_det;
  8  if s_det % isopen then
  9  loop
 10  fetch s_det into v_no,v_name,v_salary;
 11  exit when s_det%rowcount>5 or s_det%notfound;
 12  dbms_output.put_line(v_no||'  '||v_name||'  '||v_salary);
 13  end loop;
 14  commit;
 15  else
 16   dbms_output.put_line('Unable to open');
 17  end if;
 18  close s_det;
 19  end;
 20  /


OUTPUT:

s004    John         47000
s006    Tobby      47000
s007   Andrew     47000
s009      Mac        47000
s010    David       47000