in字段
in字段,就是输入,往存储过程里输入的值
CREATE procedure pdd_sum(in a int , in b 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 c=a+b;
select c;
end
call pdd_sum(100,203);
out字段
out字段就是输出,其实有点类似Java里面方法的返回值
create procedure prdd_xh(out result int)
BEGIN
set result=100;
END
call prdd_xh(@cc);
select @cc;
这里我们将存储过程的结果赋值给了@cc,@符号必须加上
然后使用select语句查询@cc的内容
inout字段
就是in字段和out字段功能的综合
create procedure prdd_add(inout a int)
BEGIN
set a=a+12;
END
set @aa=10;
call prdd_add(@aa);
select @aa;
这里我们先将@aa值设置为10,然后执行存储过程,得到的@aa就是22