学过 MySQL 之后却没有总结,今天好不容易有点时间来看看。
- delimiter //
- create proceduce sp_test(
- in id int,out num int )
- begin
- select sum(id) into num;
- end
- //
- delimiter;
- show proceduce status \G;
详细查看,可以看到具体过程中的代码内容
- show create produce sp_test\G;
- drop procedure sp_test;
将返回值存储在 num 变量中,在 out 型变量前加上 @直接可以使用
- call sp_test(1,@num);
来查看具体的值
- select @num;
--- 恢复内容结束 ---
学过之后却没有总结,今天好不容易有点时间来看看。
- delimiter // create proceduce sp_test( in id int,out num int ) begin select sum(id) into num; end // delimiter;
- show proceduce status \G;
详细查看,可以看到具体过程中的代码内容
- show create produce sp_test\G;
- drop procedure sp_test;
将返回值存储在 num 变量中,在 out 型变量前加上 @
- call sp_test(1,@num);
来查看具体的值
- select @num;
来源: