Im getting a couple of errors within my following function:
CREATE OR REPLACE FUNCTION department_salary
(emp_dept VARCHAR2, salary NUMBER)
RETURN NUMBER AS
dept_sal NUMBER := salary;
BEGIN
IF emp_dept = 'MIS' THEN dept_sal := (dept_sal * .10) + dept_sal;
ELSEIF emp_dept = 'SALES' THEN dept_sal := (dept_sal * .15) + dept_sal;
ELSEIF emp_dept = 'HR' THEN dept_sal := (dept_sal * .20) + dept_sal;
ELSE dept_sal := -1;
END IF;
RETURN dept_sal;
END;
/
The errors that I get are the following:
LINE/COL ERROR
-------- ----------------------------------------------------------------
7/10 PLS-00103: Encountered the symbol "EMP_DEPT" when expecting one
of the following:
:= . ( @ % ;
8/10 PLS-00103: Encountered the symbol "EMP_DEPT" when expecting one
of the following:
:= . ( @ % ;
14/4 PLS-00103: Encountered the symbol ";" when expecting one of the
following:
if
The problem is the syntax of the
IFstatement. In particular, the keyword isELSIFnotELSEIF(noe). If you change that, the function will compileIf you are writing code like this, however, it is generally clearer to use a
CASEstatement