Trishala213
Trishala213

Reputation: 3

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

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

Upvotes: -2

Views: 495

Answers (1)

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

Reputation: 30665

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

Upvotes: 2

Related Questions