Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION ufn_is_word_comprised (set_of_letters VARCHAR(21845), word VARCHAR(21845))
- RETURNS TINYINT(1)
- BEGIN
- DECLARE wordLength INT;
- DECLARE currentIndex INT;
- DECLARE result TINYINT(1);
- SET wordLength := CHAR_LENGTH(word);
- SET currentIndex := 1;
- SET result := 1;
- WHILE (currentIndex <= wordLength) DO
- IF(set_of_letters NOT LIKE CONCAT('%',SUBSTR(word,currentIndex,1),'%')) THEN
- SET result:= 0;
- END IF;
- SET currentIndex := currentIndex + 1;
- END WHILE;
- RETURN result;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement