MySQL中的存储函数变量

时间:2015-11-03 16:16:43

标签: mysql sql function stored-procedures stored-functions

我正在尝试在MySQL中创建一个存储函数,但是当我尝试运行该函数时,它看不到变量'InterimAPI'

代码如下:

 DELIMITER $$

 Create function 
InterimAPI_Math(test_subject char(100), grade
int(2), GradeTableValue decimal(5,2)) 

Returns decimal(6,2) Not Deterministic


 Begin
    Declare IterimAPI decimal(10,2);

    if test_subject = 'Math' AND Grade = 3 THEN
        SET @@InterimAPI = (10.9*(GradeTableValue - 253.9)) + 1000;
    elseif test_subject = 'MATH' AND GRADE = 4 THEN
        SET @@InterimAPI = (10.8*(GradeTableValue -253.4)) + 1000;
    elseif test_subject = 'MATH' AND GRDE = 5 THEN
        SET @@InterimAPI = (10.1*(GradeTableValue - 250.3)) + 1000;
    elseif test_subject = 'MATH' AND GRADE = 6 THEN
        SET @@InterimAPI = (9.4*(GradeTableValue - 246.3)) + 1000;
    elseif test_subject = 'MATH' AND GRADE = 7 THEN
        SET @@InterimAPI = (8.4*(GradeTableValue - 240.2)) + 1000;
    elseif test_subject = 'MATH' AND GRADE = 8 THEN
        SET @@InterimAPI = (8.4*(GradeTableValue - 239.8)) + 1000;
    elseif test_subject = 'Algebra I' AND GRADE = 'EOI' THEN
        SET InterimAPI = (17.4*(GradeTableValue - 71.2)) + 1000;
    END IF;

Return (InterimAPI);

END

对于属于参数的内容也略有疑惑。是表中要输入函数还是其他内容的信息?

0 个答案:

没有答案