Advertisement
Guest User

CHICHAY

a guest
Oct 13th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. DROP TABLE emp;
  2.  
  3. CREATE TABLE emp AS SELECT * FROM employees;
  4.  
  5. ALTER TABLE emp ADD stars VARCHAR2(50);
  6. Set Serveroutput on
  7. Declare
  8. Asterisk emp.stars%type:=NULL;
  9. Sal emp.salary%type;
  10. empno emp.employee_id%TYPE:=NULL;
  11. salarys emp.salary%Type;
  12.  
  13. Begin
  14.  
  15. Select employee_id, round (salary/1000), stars, salary
  16. into empno, Sal , Asterisk,salarys
  17. From emp
  18. Where employee_id=176;
  19.  
  20.  
  21.  
  22. for i in 1..50 loop
  23. if Sal = i and i between 1 and 9
  24. then
  25. update emp set stars =substr(lpad (Sal,i+1,'*'),1,i);
  26. elsif Sal=i and i between 10 and 50
  27. then
  28. update emp set stars =substr (lpad(Sal,i+2,'*'),1,i);
  29. end if;
  30. end loop;
  31.  
  32. commit;
  33.  
  34.  
  35. end;
  36. /
  37. Select employee_id, salary, stars
  38. From emp
  39. Where employee_id=176
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement