我创建了一个过程,该过程应该确定最大注册人数的班级部分。我有一个“注册”表和“部分”表。 “注册”表的“ sectionID”列为一栏,而部分表的“ sectionID”和“容量”为一列。现在我遇到的问题是,编译后我的代码根本不显示任何内容。
CREATE OR REPLACE PROCEDURE section_max AS
CURSOR enrollment_sectionID IS
SELECT SECTION_ID
FROM ENROLLMENT;
CURSOR section_sectionID IS
SELECT SECTION_ID
FROM SECTION;
CURSOR section_capacity IS
SELECT CAPACITY
FROM SECTION;
inc NUMBER(3,0);
temp_enrollment_sectionID NUMBER(8,0);
temp_section_sectionID NUMBER(8,0);
temp_section_capacity NUMBER(3,0);
BEGIN
OPEN enrollment_sectionID;
OPEN section_sectionID;
OPEN section_capacity;
LOOP
FETCH enrollment_sectionID
INTO temp_enrollment_sectionID;
EXIT WHEN enrollment_sectionID%NOTFOUND;
inc := 0;
LOOP
FETCH section_sectionID
INTO temp_section_sectionID;
FETCH section_capacity
INTO temp_section_capacity;
EXIT WHEN section_sectionID%NOTFOUND;
IF temp_enrollment_sectionID = temp_section_sectionID THEN
inc := inc + 1; --inc is the incrementer or counter
IF inc = temp_section_capacity THEN
DBMS_OUTPUT.PUT_LINE('Section ' || temp_enrollment_sectionID || ' is maxed out');
END IF;
END IF;
END LOOP;
END LOOP;
END section_max;
容量列列出了两个最大容量的部分,但是,在运行我的代码后,什么都没有显示