我无法弄清楚为什么我的代码不起作用?

时间:2015-10-06 17:07:13

标签: oracle plsql

此代码有什么问题?

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

代码的第一部分有效。 Oracle成功创建了该功能。但是,尝试使用代码的第二部分执行函数时会收到以下错误:

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.

1 个答案:

答案 0 :(得分:2)

错误消息表明您缺少语句结束分隔符,在您需要添加分号和斜杠以执行的情况下,例如:

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