PLS-00103:遇到符号 "ACCEPT" :
PLS-00103: Encountered the symbol "ACCEPT" :
任务是求一个部门同职位员工的最高工资。职位和部门编号是函数的参数。这是代码
CREATE OR REPLACE FUNCTION getMaxSalary
(jobId in employees.job_id%TYPE,
dep_id in employees.department_id%TYPE
)
RETURN NUMBER IS
result NUMBER := 0;
BEGIN
SELECT MAX(salary)INTO result
FROM employees
WHERE job_id = jobId AND department_id = dep_id;
IF result IS NULL THEN
RAISE_APPLICATION_ERROR(-20201, 'This is not a valid department');
END IF;
RETURN result;
END;
ACCEPT x CHAR PROMPT 'Please enter Job ID:'
DECLARE
jobId employees.job_id%TYPE;
maxSalary NUMBER;
BEGIN
jobId:= '&x';
maxSalary:= getMaxSalary(jobId);
DBMS_OUTPUT.PUT_LINE('The max salary for job id: '|| maxSalary);
END;
ACCEPT
适用于 SQL*Plus。您使用与 Allround Automations GUI 工具相关的 plsqldevelper
标签标记了问题。你真正用的是什么?
无论如何:尝试添加一个斜杠来终止 PL/SQL 块,这里:
...
RETURN result;
END;
/ --> here
ACCEPT x CHAR PROMPT 'Please enter Job ID:'
DECLARE
...
任务是求一个部门同职位员工的最高工资。职位和部门编号是函数的参数。这是代码
CREATE OR REPLACE FUNCTION getMaxSalary
(jobId in employees.job_id%TYPE,
dep_id in employees.department_id%TYPE
)
RETURN NUMBER IS
result NUMBER := 0;
BEGIN
SELECT MAX(salary)INTO result
FROM employees
WHERE job_id = jobId AND department_id = dep_id;
IF result IS NULL THEN
RAISE_APPLICATION_ERROR(-20201, 'This is not a valid department');
END IF;
RETURN result;
END;
ACCEPT x CHAR PROMPT 'Please enter Job ID:'
DECLARE
jobId employees.job_id%TYPE;
maxSalary NUMBER;
BEGIN
jobId:= '&x';
maxSalary:= getMaxSalary(jobId);
DBMS_OUTPUT.PUT_LINE('The max salary for job id: '|| maxSalary);
END;
ACCEPT
适用于 SQL*Plus。您使用与 Allround Automations GUI 工具相关的 plsqldevelper
标签标记了问题。你真正用的是什么?
无论如何:尝试添加一个斜杠来终止 PL/SQL 块,这里:
...
RETURN result;
END;
/ --> here
ACCEPT x CHAR PROMPT 'Please enter Job ID:'
DECLARE
...