MySQL Forums
Forum List  »  Newbie

Error: 1305 when I try to call a function in MySQL
Posted by: Mark Zeng
Date: September 27, 2018 04:16PM

I create a function called triangleType which use to define type of triangle; however, the console shows an error: SELECT triangle_type(A,B,C) FROM TRIANGLES LIMIT 0, 1000 Error Code: 1305. FUNCTION practice.triangle_type does not exist 0.00055 sec. I am not sure how to locate this function. I try to use PRACTICE.TRIANGLES but it doesn't really work. Thanks.

Schema: PRACTICE
Tables: TRIANGLES



Code:

DELIMITER $$
USE `PRACTICE`$$

CREATE FUNCTION triangleType(A int, B int, C int)
RETURNS varchar(14)

DETERMINISTIC

BEGIN
DECLARE triangle_type VARCHAR(14);
IF A = B AND B = C AND ((A+B) >C OR (A+C) >B OR (B+C) > A) THEN
SET triangle_type = "Equilateral";

ELSE IF (A=B OR B=C OR A=C) AND ((A+B) >C OR (A+C) >B OR (B+C) > A) THEN
SET triangle_type = "Isosceles";

ELSE IF (A<>B AND B<>C AND A<>C) AND ((A+B) >C OR (A+C) >B OR (B+C) > A)THEN
SET triangle_type = "Scalene";

ELSE
SET triangle_type = "Not A Triangle";
END IF;

RETURN(triangle_type);

END
DELIMITER ;


USE `PRACTICE`;
SELECT triangle_type(A,B,C) FROM PRACTICE.TRIANGLES;

Options: ReplyQuote


Subject
Written By
Posted
Error: 1305 when I try to call a function in MySQL
September 27, 2018 04:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.