Error code: 1305 MySQL, the function does not exist

I have a problem. I created a function in MySQL that returns a String (varchar data type).

Here is the syntax:

DELIMITER $$ USE `inv_sbmanis`$$ DROP FUNCTION IF EXISTS `SafetyStockChecker`$$ CREATE DEFINER=`root`@`localhost` FUNCTION `SafetyStockChecker` (jumlah INT, safetystock INT) RETURNS VARCHAR(10) CHARSET latin1 BEGIN DECLARE statbarang VARCHAR(10); IF jumlah > safetystock THEN SET statbarang = "Stabil"; ELSEIF jumlah = safetystock THEN SET statbarang = "Perhatian"; ELSE SET statbarang = "Kritis"; END IF; RETURN (statbarang); END$$ DELIMITER ; 

When I call a function like call SafetyStockChecker(16,16) , I get this error:

Request: call SecurityStockChecker (16.16)
Error Code: 1305
PROCEDURE inv_sbmanis.SafetyStockChecker does not exist
Lead time: 00: 00: 00: 000
Transfer time: 00: 00: 00: 000
Total time: 00: 00: 00: 000

What is wrong with the function?

+6
source share
2 answers

This is not the correct way to call a function. Here is an example of a function call:

 SELECT SafetyStockChecker(16,16) FROM TableName 

Now you are making a STORED PROCEDURE call. This is why the error says:

PROCEDURE inv_sbmanis.SafetyStockChecker does not exist

because it is looking for a stored procedure, not a function.

+9
source

You have to use

 SELECT SafetyStockChecker(16,16) 
+2
source

All Articles