时间:2021-07-01 10:21:17 帮助过:4人阅读
SHOW CREATE PROCEDURE ordertotal; +------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+ | Procedure | sql_mode | Create Procedure | character_set_client | collation_connection | Database Collation | +------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+ | ordertotal | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`root`@`localhost` 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 | utf8 | utf8_general_ci | utf8_unicode_ci | +------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+ 1 row in set (0.00 sec) mysql> SHOW PROCEDURE STATUS LIKE ‘ordertotal‘; +------------+------------+-----------+----------------+---------------------+---------------------+---------------+-------------------------------------------+----------------------+----------------------+--------------------+ | Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation | +------------+------------+-----------+----------------+---------------------+---------------------+---------------+-------------------------------------------+----------------------+----------------------+--------------------+ | learnmysql | ordertotal | PROCEDURE | root@localhost | 2015-06-09 11:42:48 | 2015-06-09 11:42:48 | DEFINER | Obtain order total, optionally adding tax | utf8 | utf8_general_ci | utf8_unicode_ci | +------------+------------+-----------+----------------+---------------------+---------------------+---------------+-------------------------------------------+----------------------+----------------------+--------------------+ 1 row in set (0.01 sec)
MySQL.PROCEDURE.使用存储过程
标签: