today:
197
yesterday:
221
Total:
1,109,853

IF/ELSE ... CASE WHEN

admin 2018.06.25 17:22 Views : 233

CREATE OR REPLACE PROCEDURE calsal
IS
   new_sal number;
   CURSOR sal_cursor
   IS
      SELECT deptno, empno, ename, sal
        FROM emp;
BEGIN
   FOR i IN sal_cursor
   LOOP
          if i.deptno = 10 then
               new_sal := i.sal *0.05 ;
           DBMS_OUTPUT.put_line (   ' Salary plus bonus of '
                            || i.empno
                            || ' is '
                            || (new_sal)
                           );
       elsif i.deptno = 20 then
               new_sal := i.sal *0.1 ;
           DBMS_OUTPUT.put_line (   ' Salary plus bonus of '
                            || i.empno
                            || ' is '
                            || (new_sal)
                           );
       else
                 new_sal := 0 ;
           DBMS_OUTPUT.put_line (   ' Salary plus bonus of '
                            || i.empno
                            || ' is '
                            || (new_sal)
                           );
       end if;
   END LOOP;
END;