DROP TABLE学生; COMMIT;
CREATE TABLE Student(
studentNumber INT NOT NULL,
studentName VARCHAR2(20) NOT NUll,
gender CHAR(1) NOT NULL,
highSchoolAvg INT NOT NULL,
scholarship INT DEFAULT 0,
CONSTRAINT "student_gender" CHECK (gender IN ('M', 'F')),
CONSTRAINT "student_highSchoolAvg" CHECK (highSchoolAvg BETWEEN 0 AND 100)
);
CREATE OR REPLACE PROCEDURE AcceptStudent(
studentNumberPR INT,
studentNamePR VARCHAR2,
genderPR CHAR,
highSchoolAvgPR INT)
IS
ScholarshipPr INT;
BEGIN
ScholarshipPR := 0;
IF highSchoolAvgPR >= 90 and highSchoolAvgPR <=100 THEN
ScholarshipPR := 1500;
ELSIF highSchoolAvgPR >= 85 and highSchoolAvgPR < 90 THEN
ScholarshipPR := 1000;
ELSE
raise_application_error(-20201, 'Invalid highSchool average');
END IF;
INSERT INTO Student (studentNumber, studentName, gender, highSchoolAvg, scholarship)
VALUES (studentNumberPR, studentNamePR, genderPR, highSchoolAvgPR, ScholarshipPr);
END;
exec ACCEPTSTUDENT (1, 'Ashley', 'F', 87);
exec ACCEPTSTUDENT (2, 'Will', 'M', 76);
exec ACCEPTSTUDENT (3, 'David', 'M', 94);
--Holly should be the only error--
exec ACCEPTSTUDENT (4, 'Holly', 'F', 103);
select * from student;
答案 0 :(得分:0)
您是否尝试从脚本执行所有操作?在程序之后,您在单独的一行中缺少斜杠/
。