Kross
Kross

Reputation: 1

I cannot figure out why my code will not work?

What is wrong with this code?

CREATE OR REPLACE FUNCTION get_salary_byname (e_name IN varchar2)

   RETURN NUMBER

   IS salary NUMBER;

   BEGIN

      SELECT salary

      INTO salary

      FROM emp

      WHERE ename= e_name;

      RETURN(salary);

    END;



BEGIN

DBMS_OUTPUT.PUT_LINE (get_salary_byname('JEFF'));

END

The first part of the code works. Oracle successfully creates the function. However, the following errors are received when trying to execute the function with the second part of the code:

END *ERROR at line 5:
ORA-06550: line 5, column 3: PLS-00103: Encountered the symbol "end-of-file"
when expecting one of the following: ; <an identifier>
<a double-quoted-delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.

Upvotes: 0

Views: 52

Answers (1)

Jeffrey Kemp
Jeffrey Kemp

Reputation: 60272

The error message indicates that you're missing the end-of-statement delimiter, in your case you need to add a semicolon and a slash to execute, e.g.:

BEGIN
DBMS_OUTPUT.PUT_LINE (get_salary_byname('JEFF'));
END;
/

Upvotes: 2

Related Questions