MySql从存储过程中调用存储的函数导致错误

Ron*_*dog 7 mysql sql stored-procedures stored-functions mysql-error-1064

尝试从存储过程中调用存储的函数时,我收到1064错误.它只发生在我尝试这样做的行上:SET account_id = get_account_id(user);.有什么问题,我该如何解决?

帐户ID存储功能:

CREATE DEFINER=`aaron`@`%` FUNCTION `get_account_id`(user VARCHAR(255)) RETURNS int(11)
BEGIN
    DECLARE xaccount_id INT DEFAULT 0;

   #Get Account ID and place into variable used when calling stored procedure that builds the tree structure for the leaf node portfolio id
    SELECT account_id
    FROM rst_sessions.session_data
    WHERE  username = user
    ORDER BY update_date DESC LIMIT 1
    INTO xaccount_id;

    RETURN xaccount_id;
END
Run Code Online (Sandbox Code Playgroud)

尝试调用存储函数的存储过程:

CREATE DEFINER=`aaron`@`%` PROCEDURE `build_report_portfolio_list`(user VARCHAR(255))
    READS SQL DATA
BEGIN

    DECLARE portf_id INT;
    DECLARE portf_name VARCHAR(255);
    DECLARE str_portf_parent_list VARCHAR(455);
    DECLARE done INT DEFAULT 0;
  DECLARE account_id INT;

  SET account_id = get_account_id(user);
END
Run Code Online (Sandbox Code Playgroud)

Ron*_*dog 9

我甚至不知道我试图做的是否可能,这可能导致错误.但是我找到了一个解决方法,通过调用SF作为参数来调用SP并让它做我需要它做的事情.

代码是: CALL build_report_portfolio_list(get_account_id('username_here'));