Mysql - Stored procedure OUT variable return null

大兔子大兔子 提交于 2019-12-02 04:22:20

You might have already solved this by now, but the first thing I noticed about your stored procedure is that you have a local variable with the same name as the output variable (parent_id). It looks to me that you're setting the value of the local variable rather than the return variable, so the caller never sees the correct value.

Perhaps removing the local parent_id variable declaration will solve your problem.

The syntax for setting the variable is incorrect, use : like,

SET parent_id := LAST_INSERT_ID();
 SET child_id := LAST_INSERT_ID();

or You can do the setting as

select LAST_INSERT_ID() into parent_id;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!