Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Code: 1305. FUNCTION or PROCEDURE does not exist

Tags:

mysql

So I'm creating a function in MySQL and then trying to grant permission to use that function to a user and am unable to do so. Here's what I'm doing:

DELIMITER $$

USE rxhelp36_scbn$$

DROP FUNCTION IF EXISTS `businessDayDiff` $$
CREATE FUNCTION `businessDayDiff` (start DATETIME, stop DATETIME) RETURNS TINYINT
  NO SQL
BEGIN
  RETURN 5 * (DATEDIFF(stop, start) DIV 7) + MID('0123444401233334012222340111123400001234000123440', 7 * WEEKDAY(start) + WEEKDAY(stop) + 1, 1);
END $$

GRANT EXECUTE ON PROCEDURE rxhelp36_scbn.businessDayDiff TO 'myuser'@'localhost';

Here's the error I'm getting:

Error Code: 1305. FUNCTION or PROCEDURE businessDayDiff does not exist

I don't get it. I /just/ defined the function - how does it not exist?

like image 384
neubert Avatar asked Oct 16 '25 07:10

neubert


1 Answers

Apparently I needed to do GRANT EXECUTE ON FUNCTION instead of GRANT EXECUTE ON PROCEDURE.

You'd think that if GRANT EXECUTE ON PROCEDURE only worked on PROCEDUREs that the error message ought to say "Error Code: 1305. PROCEDURE businessDayDiff does not exist" instead of "FUNCTION or PROCEDURE"...

like image 61
neubert Avatar answered Oct 17 '25 20:10

neubert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!