PL/SQL: ORA-00933: SQL command not properly ended for PL/SQL Function

482 Views Asked by At

I am trying to write a PL/SQL Function to return Nth highest Salary. I keep getting the Runtime error below. The error is on 'Return result;' line

PL/SQL: ORA-00933: SQL command not properly ended ORA-06575: Package or function GETNTHHIGHESTSALARY is in an invalid state

Code:

CREATE FUNCTION getNthHighestSalary(N IN NUMBER) RETURN NUMBER IS result NUMBER;

BEGIN

  select Salary into result
  from 
    (select dense_rank() over (order by salary desc) as Ranks, ID, Salary
     from Employee) a
     where a.Ranks = N

RETURN result;
END;

snapshot of main code

1

There are 1 best solutions below

1
Derviş Kayımbaşıoğlu On

You have missing semi-colon where a.Ranks = N. It is supposed to be where a.Ranks = N;