Guys, I have a question with Mysql about Procedures. Is it possible to save their return in a BD variable?

Asked

Viewed 38 times

0

I have a repetitive process in BD that is validate the user for each request, so I decided to create a process for this and call inside the others when necessary. However I have the need to save the return of the past this time. But I cannot allocate the value to any variable at all. I even tried to put in an if and it didn’t work out. I don’t know much back, someone can help me?


CREATE DEFINER=`root`@`localhost` PROCEDURE `getmnhsInfo`(in tokn text)
foo:BEGIN
    set @verific = verificaToken(tokn);
    if (@verific is null) then
        select tokn; -- para testar o retorno, a procedure está incompleta
    end if;
    select @verific;  -- para testar o retorno, a procedure está incompleta
END

And the error message is as follows:


Error Code: 1305. FUNCTION wmp_fut.verificaToken does not exist -- Se eu não coloco call, ele entende como uma função


Note: if I put 'call' in front it does not save with a variable together. It calls Procedure, executes it, but does not accept allocating the return to a variable.

  • 2

    Would you not want to create a FUNCTION and not a PROCEDURE?

  • Exactly! Thank you

1 answer

0


Guys, I’ll leave you the question in case anyone needs it, but I’ve decided to move the trial to function. Then the function yes, I can allocate the return the way I want.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.