日期:2014-05-17 浏览次数:21121 次
CREATE OR REPLACE FUNCTION xx_kja_test_almostfull(p_Department xx_kja_test_classes.department%TYPE,
p_Course xx_kja_test_classes.course%TYPE)
RETURN BOOLEAN IS
v_currentStudents NUMBER;
v_maxstudent NUMBER;
v_ReturnValue BOOLEAN;
v_FullPercent CONSTANT NUMBER := 90;
BEGIN
SELECT current_students, max_students
INTO v_currentStudents, v_maxStudents
FROM Xx_Kja_Test_Classes
WHERE department = p_Department --根据条件过滤出记录,找出current_students, max_students赋值给v_currentStudents, v_maxStudents两个变量
AND course = p_Course;
IF (v_CurrentStudent / v_MaxStudents * 100) > v_FullPercent THEN --if判断语句,当v_CurrentStudent / v_MaxStudents大于百分之90时,给返回值赋值true,否则false
v_ReturnValue := TRUE;
ELSE
v_ReturnValue := FALSE;
END IF;
RETURN v_ReturnValue; --返回值
END almostfull;