Raise power function : Utility Function « Stored Procedure Function « Oracle PL / SQL






Raise power function

  
SQL>
SQL> SET ECHO ON
SQL>
SQL> CREATE OR REPLACE FUNCTION RAISE(
  2            p1 INTEGER,
  3            p2 NUMBER)
  4       RETURN NUMBER IS
  5       p3 NUMBER;
  6  BEGIN
  7       IF p1 = 1 THEN
  8            p3 := p2 * 1.10;
  9       ELSIF p1 = 2 THEN
 10            p3 := p2 * 1.05;
 11       ELSIF p1 = 3 THEN
 12            p3 := p2 * 1.04;
 13       ELSIF p1 = 4 THEN
 14            p3 := p2 * 1.03;
 15       ELSIF p1 = 5 THEN
 16            p3 := p2 ;
 17       ELSE
 18            p3 := p2 * 1.02;
 19       END IF;
 20       RETURN p3; --
 21  END RAISE;
 22  /

Function created.

SQL>
SQL>
SQL> select raise(2,3) from dual;
RAISE(2,3)
----------
      3.15

1 row selected.

SQL>
SQL> --

   
  








Related examples in the same category

1.Your own month add method
2.Raise pay level
3.Validate date value format
4.Function to update null value
5.Function to count tab
6.Calculate average grade
7.Temperature package: convert Celsius to Fahrenheit back, forth