Reputation: 4166
I'm trying to check class
using MySQL procedure, but the following procedure always returns 0:
DELIMITER //
CREATE PROCEDURE `validate_class`(IN `class` INT)
BEGIN
if(class NOT IN ('A','B','E') ) then
select 1;
else
select 0;
end if;
END //
DELIMITER ;
call test:
call validate_class('G'); //return 0
call validate_class('A'); //return 0
It should return 1
when class isn't (A
and B
and E
), any help?
Upvotes: 3
Views: 528
Reputation: 175954
You have implicit conversions CHAR
-> INT
-> CHAR
.
Change parameter datatype:
CREATE PROCEDURE `validate_class`(IN `class` CHAR(1))
BEGIN
if(class NOT IN ('A','B','E') ) then
select 1;
else
select 0;
end if;
END
Upvotes: 3