【发布时间】:2019-08-08 10:09:19
【问题描述】:
我正在尝试使用 Oracle Developer 在 PL/SQL 中编写一个过程,该过程从 PROMPT 获取输入,如果没有输入输入,则使用异常处理程序输出。我的提示窗口显示“请输入 p_first_name 的值”,而不是我在“...”中的值。在提示中输入数据后,出现以下错误:
Error(6,21): PLS-00103: Encountered the symbol "PROMPT" when expecting one of the following: := . ( @ % ; not null range default character
代码
SET SERVEROUTPUT ON
CREATE PROCEDURE print_name (first_name IN varchar, last_name varchar,
title varchar) IS
ACCEPT p_first_name PROMPT 'Please enter a first name:'
ACCEPT p_last_name PROMPT 'Please enter a second name:'
ACCEPT p_title PROMPT 'Please enter a second name:'
DECLARE
first_name varchar :=&p_first_name;
last_name varchar :=&p_last_name;
title varchar :=&p_title;
first_null EXCEPTION;
last_null EXCEPTION;
title_null EXCEPTION;
BEGIN
IF first_name IS NULL THEN
raise first_null;
END IF;
IF last_name IS NULL THEN
raise last_null;
END IF;
IF title IS NULL THEN
raise title_null;
END IF;
DBMS_OUTPUT.PUT_LINE(last_name || ',' || first_name || ' ' || title);
EXCEPTION
WHEN first_null THEN
DBMS_OUTPUT.PUT_LINE('You must enter a first name.');
WHEN last_null THEN
DBMS_OUTPUT.PUT_LINE('You must enter a last name.');
WHEN title_null THEN
DBMS_OUTPUT.PUT_LINE('You must enter a title.');
END;
/
输入第一个、最后一个和标题后,我希望打印:
Doe, Jane Ms.
如果任何值为 NULL,我希望异常处理程序能够打印。
到目前为止,我只收到以下错误:
Error(6,21): PLS-00103: Encountered the symbol "PROMPT" when expecting one of the following: := . ( @ % ; not null range default character
【问题讨论】:
标签: sql