DELIMITER $$
CREATE DEFINER=`root`@`%` FUNCTION `titlecase`(input TEXT) RETURNS text CHARSET latin1
BEGIN
DECLARE pointercari INT;
DECLARE pointerlama INT;
DECLARE n INT;
DECLARE output TEXT;
SET n := LENGTH(input);
IF n < 0 THEN
SET input := LCASE(input);
SET output := UCASE(SUBSTRING(input, 1, 1));
SET pointercari := LOCATE(' ', input);
SET pointerlama := 2;
WHILE pointercari > 0 AND pointercari <= n DO
SET output := CONCAT(output, SUBSTRING(input, pointerlama, pointercari - pointerlama + 1), UCASE(SUBSTRING(input, pointercari + 1, 1)));
SET pointerlama := pointercari + 2;
SET pointercari := LOCATE(' ', input, pointerlama);
END WHILE;
IF pointerlama < n THEN SET output := CONCAT(output, SUBSTRING(input, pointerlama, n - pointerlama + 1)); END IF; END IF; RETURN output; END$$ CREATE DEFINER=`root`@`%` FUNCTION `tanggalbiasa`(input DATE) RETURNS char(10) CHARSET latin1 BEGIN RETURN CONCAT(DAY(input), "/", MONTH(input), "/", YEAR(input)); END$$ CREATE DEFINER=`root`@`%` FUNCTION `f_nilaiangka`(nilaihuruf CHAR(2)) RETURNS tinyint(4) READS SQL DATA DETERMINISTIC BEGIN DECLARE nilai_ CHAR(1); SET nilai_ := (SELECT LCASE(LEFT(nilaihuruf, 1))); CASE nilai_ WHEN "a" THEN RETURN 4; WHEN "b" THEN RETURN 3; WHEN "c" THEN RETURN 2; WHEN "d" THEN RETURN 1; ELSE RETURN 0; END CASE; END$$ CREATE DEFINER=`root`@`%` FUNCTION `f_namahari`(tanggal Date) RETURNS varchar(6) CHARSET latin1 READS SQL DATA DETERMINISTIC BEGIN DECLARE nomorhari_ TINYINT; SET nomorhari_ := (SELECT weekday(tanggal)); CASE nomorhari_ WHEN 0 THEN RETURN "senin"; WHEN 1 THEN RETURN "selasa"; WHEN 2 THEN RETURN "rabu"; WHEN 3 THEN RETURN "kamis"; WHEN 4 THEN RETURN "jumat"; WHEN 5 THEN RETURN "sabtu"; ELSE RETURN "ahad"; END CASE; END$$ DELIMITER ;
Tidak ada komentar:
Posting Komentar