我正在尝试执行以下步骤: 1.提示用户输入三个,course_no,离开和注册。 2.检查我的部门表中是否找到了离开。 3.如果找到,请检查满足条件的可用房间。如果没有,请打印消息。
这是我的代码:
ACCEPT course_no number PROMPT "Enter course_no: ";
ACCEPT depart PROMPT "Enter Department name: ";
ACCEPT Enrollment number PROMPT "Enter Enrollment: ";
DECLARE
deptFound number;
availableRooms number;
roomNumber number;
BEGIN
select case
when exists (select 1 from dept where code = '&depart')
then 1
else 0
end as d_exist
into deptFound
from dual;
if deptFound = 1 then
select count(*) into availableRooms from rooms where capacity > &enrollment;
if availableRooms > 0 then
select room_no into roomNumber from rooms r where capacity = ( select min(capacity) from rooms where capacity > &enrollmen) and rownum = 1;
else
DBMS_OUTPUT.PUT_LINE('No available rooms!');
end if;
end if;
END;
/
然而,当我运行它时,它会询问我course_no,部门名称和注册,然后它会提示我:
Enter value for enrollmen:
我的代码中甚至没有提示。它来自哪里?
答案 0 :(得分:2)
嗯,你确实在你的代码中有这个。但要看到它,你需要了解替代变量。见Configuration Manager。在这种特殊情况下,提示实际上存在两次:
“从容量> & enrollment ”的房间中选择计数(*)到可用房间
再次
“......来自容量> & enrollment 的房间......”