Because of work requirements, you need to write a mysql custom number of rows, as shown below: DELIMITER $ DROPFUNCTIONIFEXISTS 'onlinefunction '$ CREATEFUNCTION 'onlinefunction' (rrrrVARCHAR (50) RETURNSVARCHAR (255) BEGINIF (rrrronline) THENRETURN goes live; ENDIF; END $ DELIMITER;
Because of work requirements, you need to write a mysql custom number of rows, as follows: DELIMITER $ drop function if exists 'onlinefunction '$ create function 'onlinefunction' (rrrr VARCHAR (50 )) returns varchar (255) BEGINIF (rrrr = 'online') then return 'online'; end if; END $ DELIMITER;
To customize the number of mysql rows
DELIMITER $ drop function if exists 'onlinefunction '$ create function 'onlinefunction' (rrrr VARCHAR (50) returns varchar (255) BEGINIF (rrrr = 'online ') then return 'online'; end if; END $ DELIMITER;
The first line of DELIMITER defines an end identifier. because MySQL uses a semicolon as the end character of an SQL statement by default, and a semicolon is used inside the function body, it will conflict with the default SQL end character, therefore, you must first define another symbol as the SQL Terminator. If this definition is not added...
Error code: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'end' at line 1
The second line is to delete the class with the same name, otherwise it will...
Error code: 1304 FUNCTION onlineFunction already exists
Row 3 function name, function variable, and return type
The fourth line, begin, is the start and corresponds to end $.
The fifth line is the if judgment Statement, in the format
if(...) then....;elseif....;else.....;end if;return ..;
Sometimes mysql cannot create a UDF because function 2 is not enabled.
Enter the show variables like '% func %' command.
The status of log_bin_trust_function_creators is displayed. If it is OFF, the UDF function is disabled.
Enter the command set global log_bin_trust_function_creators = 1;
You can enable the UDF function for log_bin_trust_function_creators.
However, this setting is a temporary solution, because the status changes to OFF after mysql is automatically restarted, so you need
Add the "-- log-bin-trust-function-creators = 1" parameter when the service is started.
Or add log-bin-trust-function-creators = 1 in the [mysqld] section of my. ini (my. cnf.