Reading Notes-MySQL stored procedure-storage function _ MySQL

Source: Internet
Author: User
Reading Notes-MySQL stored procedure-storage function bitsCN.com

The differences between stored functions and stored procedures are as follows:

1. IN the function parameter list, the mode can only be IN.

2. the function must return a value. its type is defined in the function header.

3. functions can be called by SQL statements.

4. the function may not return any result set.

DELIMITER $ drop function if exists discount_price $ create function discount_price normal_price NUMERIC (8, 2) return numeric (8, 2) deterministicbegin declare v_discount_price NUMERIC (8, 2 ); IF (normal_price> 500) then set discount_price = normal_price *. 8; else if (normal_price> 1000) then set discount_price = normal_price *. 9; else set discount_price = normal_price; end if; RETURN (discount_price); END $

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.