直接上代码:
mysql_connect("localhost","user","pwd");
mysql_select_db('testdata') or die (mysql_error());
$sql = "create procedure tb_neaten (in rec int,in pa varchar(15),in qy decimal(10,2),in ar varchar(6))
begin
update test1 set qty=qty-qy where recordnum=rec;
insert into test2 set bname=pa,area=ar,qty=qy,date=date_format(now(),'%Y%m%d'),time=date_format(now(),'%Y%m%d');
end;";
mysql_query($sql) or die (mysql_error());
若是存储过程里含有捕获select结果的语句时,需在mysql_connect时调整参数
mysql_connect("localhost","user","password",1,131072)
执行时,直接运行
mysql_query(tb_neaten(va1,va2,va3,va4));
MySQL教程4 MySQL8运算符、函数、存储过程及新增数据类型 17.之创建带有IN和OUT参数的存储过程 学习猿地