mysql存储过程实例演示
程序员文章站
2024-02-14 15:09:34
1:简单示例 加法
create definer=`root`@`%` procedure `add_procedure`(in a int,in b int,out sum int)
b...
1:简单示例 加法
create definer=`root`@`%` procedure `add_procedure`(in a int,in b int,out sum int) begin declare c int; if a is null then set a = 0; end if; if b is null then set b = 0; end if; set sum = a + b; end
调用:
call new_procedure(2,2,@s); select @s as sum;
输出为4
2:查询某个表格所有数据
create definer=`root`@`%` procedure `select_all_procedure`() begin select count(*) from users; end
调用
call new_procedure();
输出个数