初试mysql存储过程,记录一下
今天第一次试用mysql的存储过程,最后发现不太适合我的需要,存储过程不能传递数组作为参数...
下面一小段代码,记录一下学习的过程:
delimiter //drop procedure if exists queryCount//create procedure queryCount(out cnt int)begindeclare count int;select count(*) into count from table_xxx;set cnt = count;end//delimiter ;
代码里面,其实可以直接select count(*) into cnt的,因为我想试试它的赋值操作,所以用了一个中间变量。
顺便给出mysql doc的地址,我没全看完,挑一些看了看:http://dev.mysql.com/doc/refman/5.1/zh/stored-procedures.html