This is MySql code Alter Function
DELIMITER $$
ALTER FUNCTION Tepat(tgl_permohonan DATETIME, total_hari_kerja INT)
RETURNS INT WITH EXECUTE AS CALL AS BEGIN
DECLARE jumlah_hari INT, i INT, selisih INT;
SET i = 0;
SET jumlah_hari = 0;
WHILE (i < total_hari_kerja)
BEGIN
IF (EXTRACT(WEEK FROM tgl_permohonan) != 6) AND (EXTRACT(WEEK FROM tgl_permohonan) != 5)
BEGIN
SET i = i + 1;
END IF;
SET jumlah_hari = jumlah_hari + 1;
SET tgl_permohonan = DATE_ADD(tgl_permohonan, INTERVAL 1 DAY);
END;
SET selisih = DATEDIFF(tgl_permohonan, NOW());
IF selisih <= 0
BEGIN
SET selisih = 0;
END IF;
RETURN selisih;
END; $$
DELIMITER ;
getting the following error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(tgl_permohonan DATETIME, total_hari_kerja INT) RETURNS INT WITH EXECUTE AS CALL AS BEGIN' at line 1
In order to change a stored function in MySQL you have to drop and recreate it.
DROP FUNCTION Tepat;
CREATE FUNCTION Tepat(...
ALTER FUNCTION only let you change the characteristics (like COMMENT or DEFINER) of a function.
ALTER FUNCTION Syntax
This statement can be used to change the characteristics of a stored function. More than one change may be specified in an ALTER FUNCTION statement. However, you cannot change the parameters or body of a stored function using this statement; to make such changes, you must drop and re-create the function using DROP FUNCTION and CREATE FUNCTION.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With