MySQL 存储过程的 BEGIN 和 END
时间:2016-05-26 13:49 来源:linux.it.net.cn 作者:IT
mysql>
mysql> DELIMITER //
mysql> CREATE FUNCTION myProc (cost DECIMAL(10,2))
-> RETURNS DECIMAL(10,2)
->
-> SQL SECURITY DEFINER
->
-> tax: BEGIN
-> DECLARE order_tax DECIMAL(10,2);
-> SET order_tax = cost * .05;
-> RETURN order_tax;
-> END
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;
mysql>
mysql> select myProc(123.45);
+----------------+
| myProc(123.45) |
+----------------+
| 6.17 |
+----------------+
1 row in set, 1 warning (0.00 sec)
mysql>
mysql> drop function myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
(责任编辑:IT)
mysql> mysql> DELIMITER // mysql> CREATE FUNCTION myProc (cost DECIMAL(10,2)) -> RETURNS DECIMAL(10,2) -> -> SQL SECURITY DEFINER -> -> tax: BEGIN -> DECLARE order_tax DECIMAL(10,2); -> SET order_tax = cost * .05; -> RETURN order_tax; -> END -> // Query OK, 0 rows affected (0.00 sec) mysql> DELIMITER ; mysql> mysql> select myProc(123.45); +----------------+ | myProc(123.45) | +----------------+ | 6.17 | +----------------+ 1 row in set, 1 warning (0.00 sec) mysql> mysql> drop function myProc; Query OK, 0 rows affected (0.00 sec) mysql> (责任编辑:IT) |