Calling a Stored Procedure in a Stored Procedure in MySQL(在 MySQL 中的存储过程中调用存储过程)
问题描述
我在任何地方都找不到这个答案,但是您可以从 MySQL 中的另一个存储过程调用存储过程吗?我想取回标识值并在父存储过程中使用它.我们不能再使用 FUNCTIONS!
I can't find this answer anywhere, but can you call a Stored Procedure from another Stored Procedure in MySQL? I want to get the Identity Value back and use it in the parent Stored Procedure. We can't use FUNCTIONS anymore!
推荐答案
CREATE PROCEDURE innerproc(OUT param1 INT)
BEGIN
insert into sometable;
SELECT LAST_INSERT_ID() into param1 ;
END
-----------------------------------
CREATE PROCEDURE outerproc()
BEGIN
CALL innerproc(@a);
// @a gives you the result of innerproc
SELECT @a INTO variableinouterproc FROM dual;
END
OUT
参数应该可以帮助您将值返回给调用过程.基于此,解决方案必须是这样的.
OUT
parameters should help you in getting the values back to the calling procedure.Based on that the solution must be something like this.
这篇关于在 MySQL 中的存储过程中调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 MySQL 中的存储过程中调用存储过程


基础教程推荐
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01