存储过程begin/end

时间:2022-02-10 22:50:54
drop table if exists t;

create table t (s1 int);  
  
insert into t values (5);  

select * from t;

-- --------------------------------------------------

drop procedure if exists p7;

delimiter //

create procedure p7()  
begin  
  set @a = 6;  
  set @b = 5;  -- 定义两个客户端变量
  insert into t values (@a);  
  select s1 * @a from t where s1 >= @b;  
end; // 

delimiter ;

call p7();

/*
+---------+
| s1 * @a |
+---------+
|      30 |
|      36 |
+---------+
*/