In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about the use of mysql storage functions. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
What is a storage function:
Encapsulate a piece of sql code, complete a specific function, and return the result.
Syntax for storing functions:
Create function function ([function arguments],... .]) Returns return type Begin If (Return) Else Return (returned data) end if; end
For example:
Create function count_news (hits int) returns int
Unlike the stored procedure return parameters, the stored function does not directly declare which variable is the return parameter when it is defined, but only uses returns to declare the data type to which the return parameter belongs, and the return parameter is expressed in the function body in the form of the data variable returned by return. What we should pay attention to is:
The storage function only supports input parameters, and there is no IN or INOUT before input parameters.
Limitations in storage functions
Flow control (Flow-of-control) statements (IF, CASE, WHILE, LOOP, WHILE, REPEAT, LEAVE,ITERATE) are also legal.
Variable declaration (DECLARE) and assignment (SET) are legal.
Conditions are allowed to be declared.
Exception handling declarations are also allowed.
But keep in mind here that the function has restrictions: you cannot access the table in the function. Therefore, it is illegal to use the following statement in a function.
ALTER 'CACHE INDEX' CALL COMMIT CREATE DELETE DROP' FLUSH PRIVILEGES' GRANT INSERT KILL LOCK OPTIMIZE REPAIR REPLACE REVOKE ROLLBACK SAVEPOINT 'SELECT FROM table'' SET system variable' 'SET TRANSACTION' SHOW' START TRANSACTION' TRUNCATE UPDATE Thank you for reading! On the use of mysql storage functions to share here, I hope that the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.