CS1103/Labs/Lab7/Procedure.sql

19 lines
694 B
MySQL
Raw Permalink Normal View History

2022-10-07 00:48:09 -03:00
DELIMITER \\
CREATE PROCEDURE AcceptStudent (
studentName VARCHAR(256),
emailAddress VARCHAR(256),
hsAverage FLOAT
)
BEGIN
IF (hsAverage < 0) OR (hsAverage > 100) THEN
SIGNAL SQLSTATE '45005'
SET MESSAGE_TEXT = 'High School average out of range.';
ELSEIF (hsAverage > 90) THEN
INSERT INTO Students(studentName, email, scholarship) VALUES (studentName, emailAddress, 1500);
ELSEIF (hsAverage >= 85) OR (hsAverage <= 90) THEN
INSERT INTO Students(studentName, email, scholarship) VALUES (studentName, emailAddress, 1000);
ELSE
INSERT INTO Students(studentName, email, scholarship) VALUES (studentName, emailAddress, 0);
END IF;
END\\
DELIMITER ;