I am new to mysql function and store procedure.Here is my function of mysql with function name create_role that takes argument role_name.What I have to do is If there is any row with with particular role name then it should return 1 or true, if there is no role then it should return 0 or false.
CREATE FUNCTION create_role ( role_name VARCHAR(100))
RETURNS INT
BEGIN
DECLARE check_role INT;
SET check_role = 0;
SELECT * from role where role.role=role_name into check_role;
RETURN check_role;
END
delimiter //at the beginning and//at the end of the function definition.