MYSQL入门学习之十二:存储过程的基本操作(二)

2014-11-24 14:38:38 · 作者: · 浏览: 2
r_set_client |
+------+---------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+-
| test | sp_test | PROCEDURE | root@localhost | 2012-12-17 23:57:38 | 2012-12-17 23:57:38 | DEFINER | | latin1 |
+------+---------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+-
www.2cto.com
6、使用存储过程参数
示例:
[sql]
mysql> delimiter //
mysql> create procedure sp_type_cnt(
-> IN in_type int,
-> OUT out_cnt int
-> )
-> begin
-> select count(*)
-> from newname
-> where type = in_type
-> into out_cnt;
-> end;
-> //
mysql> delimiter ;
mysql> call sp_type_cnt(0,@cnt);
mysql> select @cnt;
+------+
| @cnt |
+------+
| 159 |
+------+