让我们首先创建一个存储过程-mysql> delimiter //
mysql> create procedure declare_demo_sp()
begin
declare Value1 int;
declare Value2 int;
set Value1=100;
set Value2=2000;
select Value1,Value2,Value1*Value2 as MultiplicationResult;
end
//
mysql> delimiter ;
使用CALL命令调用存储过程-mysql> call declare_demo_sp();
这将产生以下输出-+--------+--------+----------------------+
| Value1 | Value2 | MultiplicationResult |
+--------+--------+----------------------+
| 100 | 2000 | 200000 |
+--------+--------+----------------------+
1 row in set (0.00 sec)