Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.51 KB | None | 0 0
  1. CREATE FUNCTION ufn_is_word_comprised (set_of_letters VARCHAR(21845), word VARCHAR(21845))
  2. RETURNS TINYINT(1)
  3. BEGIN
  4.     DECLARE wordLength INT;
  5.     DECLARE currentIndex INT;
  6.     DECLARE result TINYINT(1);
  7.     SET wordLength := CHAR_LENGTH(word);
  8.     SET currentIndex := 1;
  9.     SET result := 1;
  10.    
  11.      WHILE  (currentIndex <= wordLength) DO
  12.         IF(set_of_letters NOT LIKE CONCAT('%',SUBSTR(word,currentIndex,1),'%')) THEN
  13.             SET result:= 0;
  14.         END IF;
  15.         SET currentIndex := currentIndex + 1;
  16.     END WHILE;
  17.    
  18.     RETURN result;
  19. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement