Because work requires, write a custom number of MySQL lines, as follows
DELIMITER $$
DROP FUNCTION IF EXISTS ' onlinefunction ' $$
CREATE FUNCTION ' onlinefunction ' (rrrr VARCHAR (50)) RETURNS VARCHAR (255)
BEGIN
IF (rrrr= ' online ') THEN return ' online '; End IF;
end$$
DELIMITER;
The first line delimiter defines a closing identifier, because MySQL defaults to the Terminator of the SQL statement, and the function body uses a semicolon, so it conflicts with the default SQL terminator, so you need to first define a different symbol as the end of SQL. Without adding this definition ...
Error code: 1064 You have a error in your SQL syntax check the manual this corresponds to
your MySQL server version for the Right syntax to use near ' end ' in line 1
The second line is to delete the class with the same name, or ...
Error code: 1304
FUNCTION onlinefunction already exists
Third line first function name, function variable, and return type
Line four begins with the beginning, corresponds to the end$$
Line Five is the IF Judgment statement, formatted as
if (...) then ...
;
ElseIf ...
;
else
...;
End If;
return ...;
Sometimes MySQL cannot create a custom function because the feature 2 is not turned on
Enter show variables like '%func% '; Command
You will see the state of the log_bin_trust_function_creators, and if it is off, the custom function function is turned off.
Input command set global Log_bin_trust_function_creators=1;
You can turn log_bin_trust_function_creators on the custom function function
But this setting is a temporary scenario, because the MySQL automatically restarts and the state turns off again, so you need to
Add the "--log-bin-trust-function-creators=1" parameter when the service starts.
Or add Log-bin-trust-function-creators=1 to the [mysqld] section in My.ini (MY.CNF).