mysql智能存储过程
程序员文章站
2022-04-20 17:13:52
...
创建存储过程:
CREATE procedure ordertotal( in onumber int, in taxable boolean, out ototal decimal(8,2) ) COMMENT 'Obtain order total,optionally adding tax' begin DECLARE total decimal(8,2); declare taxrate int DEFAULT 6; SELECT sum(item_price * quantity) from orderitems where order_num = onumber into total; if taxable then SELECT total+(total/100*taxrate) into total; end if; SELECT total into ototal;
end;
调用存储过程:taxable为真
call ordertotal(20005,1,@total);
SELECT @total;
调用存储过程:taxable为假
call ordertotal(20005,1,@total);
SELECT @total;
以上就是mysql智能存储过程的内容,更多相关内容请关注PHP中文网(www.php.cn)!
推荐阅读
-
SQL Server 存储过程 数组参数 (How to pass an array into a SQL Server stored procedure)
-
MySQL存储表情时报错:java.sql.SQLException: Incorrect string value:‘\xF0\x9F\x92\xA9\x0D
-
SQL存储过程初探
-
通用分页存储过程,源码共享,大家共同完善
-
sql server中千万数量级分页存储过程代码
-
数据库分页存储过程代码
-
创建存储过程提示:名称已由现有对象使用
-
【Mysql】Mysql主从库搭建过程(爬完坑后整理所得)
-
Linux下Mysql5.6 二进制安装过程
-
Oracle 存储过程发送邮件实例学习