MYSQL存储过程以及结果集

#存储过程
delimiter //
create procedure p1()
begin
select * from t1;
end//
delimiter ;
#执行存储过程
call p1() 

#创建存储过程
delimiter \\
create procedure p1(
in i1 int, 
in i2 int,
inout i3 int,
out rl int
)
BEGIN
DECLEAR temp1 int;
DECLEAR temp2 int default 0;

set temp1 = 1;

set rl = i1 + i2 + temp1 + temp2;

set i3 = i3 + 100;
end\\
delimiter ;

--执行存储过程
set @t1 = 4;
set @t2 = 0;
CALL p1 (1, 2, @t1, @t2);
SELECT @t1, @t2;

#结果集

delimiter // 
create procedure p1()
begin 
select * from v1;
end //
delimeiter;


#结果集+out值
delimiter // 
create procedure p2(
in n1 int,
inout n3 int,
out n2 int,
)
begin 
declear temp1 int;
declear temp2 int default 0;
select * from v1;
set n2 = n1 + 100;
set n3 = n3 + n1 + 100;
end //
delimiter;

相关推荐