DELIMITER$$
DROP FUNCTION IF EXISTS hitungvok$$
CREATE FUNCTION hitungvok (kalimat VARCHAR(255))
RETURNS INT
BEGIN
DECLARE hasil INT DEFAULT 0;
SET @jumlah = LENGTH(kalimat);
SET @i=0;
WHILE @i <= @jumlah DO
IF FIND_IN_SET(RIGHT(LEFT(kalimat,@i),1),'a,A,i,I,u,U,e,E,o,O') THEN
SET hasil = hasil+1;
END IF;
SET @i = @i+1;
END WHILE;
RETURN hasil;
END$$
SELECT hitungvok ('I KETUT BAGUS MERTA HADI') AS hasil;
DROP FUNCTION IF EXISTS hitungvok$$
CREATE FUNCTION hitungvok (kalimat VARCHAR(255))
RETURNS INT
BEGIN
DECLARE hasil INT DEFAULT 0;
SET @jumlah = LENGTH(kalimat);
SET @i=0;
WHILE @i <= @jumlah DO
IF FIND_IN_SET(RIGHT(LEFT(kalimat,@i),1),'a,A,i,I,u,U,e,E,o,O') THEN
SET hasil = hasil+1;
END IF;
SET @i = @i+1;
END WHILE;
RETURN hasil;
END$$
SELECT hitungvok ('I KETUT BAGUS MERTA HADI') AS hasil;
0 komentar:
Posting Komentar