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