5

I am trying to call a function from another function as below, but it is throwing an error as mentioned below

CREATE DEFINER=`root`@`localhost` FUNCTION `all_function`(runInstance double) RETURNS int(11)
BEGIN
CALL al_compareData(runInstance);

RETURN 1;
END

error thrown is

Error Code: 1305. PROCEDURE als.al_compareData does not exist

I am trying to call a function, but MySQL in turn is searching for a procedure.

How to call a function from another function

1 Answer 1

5

What if you omit CALL and just use al_compareData(runInstance);

CALL is meant to be used with procedures only. What the function returns is meant to be used/assigned in your block. Also, if you try

SELECT al_compareData(runInstance);

outside your procedure, it will return the result, just for you to know.

Maybe you want to use the value returned, so you could do something like

SET compareResult = al_compareData(runInstance);
IF (compareResult) THEN
    --something
ELSE
    --something else
END IF;
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.