sql - Whats the error in this mysql syntax? -
i pretty new forthe world of mysql. i'm trying create procedure decide class of student his/her gpa. gave them cregno going 1 10 @ time. here's code:
mysql> delimiter // mysql> create procedure decideclass () -> begin -> declare count int; -> declare max int; -> set count = 1; -> set max = 10; -> declare fclass char(18) default 'first class honors'; -> declare supper char(34) default 'second class honors-upper division'; -> declare slower char(34) default 'second class honors-lower division'; -> declare tclass char(18) default 'third class honors'; -> while count <= max -> declare gpa decimal(3,2); -> set gpa = (select gpa student cregno = count); -> if gpa >= 3.7 -> update student set class = fclass cregno = count; -> else if gpa < 3.7 , gpa >= 3.3 -> update student set class = supper cregno = count; -> else if gpa < 3.3 , gpa >= 2.7 -> update student set class = slower cregno = count; -> else if gpa < 2.7 , gpa >= 2.0 -> update student set class = tclass cregno = count; -> end if -> set count = count + 1; -> end while; -> end; -> //
then says
error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near 'declare fclass char(18) default 'first class honors'; declare supper char(34) de' @ line 7
can me out here ? whats error ?
all of declare
statements must @ beginning, before set
s or else.
Comments
Post a Comment