存储过程
为什么要使用存储过程
存储过程的缺陷
使用存储过程
创建存储过程
delimiter // //修改定界符 create procedure ordertotal(in onnumber int,out ototal decimal(10,2)) begin select sum(item_price * quantity) from orderitems where order_num=onnumber into ototal; end//
使用存储过程
delimiter ; //修改定界符 call ordertotal(2005,@total) end// select @taltal; // 调用存储过程 @taltal(变量)
修改存储过程
delimiter // create procedure ordertotal(in onnumber int,in taxable boolean,out ototal decimal(10,2)) begin declare total decimal(10,2); declare taxrate int default 6; select sum(item_price * quantity) from orderitems where order_num = onumber into total; if taxable then select total * (1+taxrate/100) into total; end if; select total into ototal; end // call ordertotal(2005,0,@ototal)// select @ototal// show create procedure ordertotal// 查看创建语句
删除存储过程
drop procedure ordertotal//