Home > Database > Mysql Tutorial > body text

MySQL 存储过程的 BEGIN 和 END

WBOY
Release: 2016-06-07 14:54:26
Original
4400 people have browsed it

无详细内容 MySQL mysqlmysql 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; -

MySQL
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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template