MySQL Custom function call does not produce results

Source: Internet
Author: User

Code for custom functions:

drop FUNCTION IF EXISTS fn_hrstaffbase_getnamefromidcard
Delimiter//
CREATE FUNCTION Fn_hrstaffbase_getnamefromidcard (a VARCHAR ())
RETURNS VARCHAR ()
Begin
Return (SELECT staff_ name   from hr_staff_base where idcard = a);
END//

-- ------------------------------------------------------------------------------------------------------------- --------

Function call Query:

Select Fn_hrstaffbase_getnamefromidcard (' 299012234225 ')

-- ------------------------------------------------------------------------------

It's all null,

Processing method:

When you create a new library, you must

You can also modify the database settings: Right-click the database, mouse to edit the database

To set up a database such as:

The original settings are:

The database can read only Latin values and cannot read Chinese

So the result of calling the function is:

-- ---------------------------------------------------------------

After you modify the database settings, the query results appear:

#################################################################################

Sometimes MySQL cannot build a custom function because the function 2 is not turned on

Enter show variables like '%func% '; Command

You will see the state of the log_bin_trust_function_creators, if it is off, the function of the custom function is closed

Input command set global Log_bin_trust_function_creators=1;

Log_bin_trust_function_creators can be turned on with custom function functions

However, this setting is a temporary scenario because the status will turn off after MySQL automatically restarts, 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 in the [mysqld] section of My.ini (MY.CNF).

MySQL Custom function call does not produce results

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.