Create user-defined functions in mysql
Create a user-defined function in mysql _ MySQL
To prevent the mid-process output produced by semicolons, define a separator. here, we use the mysql official example: use two dollar signs $ as the separator, the following code is used to create a prototype of a user-defined mysql function. you can modify it on this basis so that the creation of a function will not produce many errors.
Set global log_bin_trust_function_creators = 1; -- enable the bin_log replication FUNCTION to create the drop function if exists hello; -- delete an existing DELIMITER $ -- defines the DELIMITER, which must be, it may not be $ create function hello (s varchar (30) -- Multiple parameters are used. the split parameter type must be the returns varchar (255) type existing in the mysql column) -- specify the return value type. if you are not sure about the length of the returned text, you can use textBEGIN DECLARE str varchar (255) default 'hello'; -- to define a variable, you can specify the default value SET str = concat (str, s); -- SET the value of the edge variable RETURN str; -- RETURN value END $ -- be sure to see clearly The end is followed by the DELIMITER $ defined earlier.
The above is the content for mysql to create user-defined function _ MySQL. For more information, please follow the PHP Chinese network (www.php1.cn )!