MySQL error set

Source: Internet
Author: User
Tags mysql functions

I encountered many problems when I used MySQL to write functions today. Now I will write down the problems and solutions.

1: in MySQL, a semicolon (-) is required for each row ,--!

Second, the result set cannot be returned in MySQL functions. therefore, select * From tablename and select column_name from tablename cannot be used. otherwise, the error not allowed to return aresult set from a function is reported. change the select XX into method ..

Third: error message :"This function has none of deterministic, no SQL, or reads SQL data in its declaration and binary"

we should have enabled bin-log, we must specify whether our function is
1 uncertain deterministic
2 No SQL statement, of course, the data will not be modified.
3 reads SQL data only reads data, of course, the data will not be modified.
4 modifies SQL data
5 contains SQL statements

In the function, only deterministic, no SQL, and reads SQL data are supported. If bin-log is enabled, we must specify a parameter for our function.

we can disable this by setting the following parameters.

set global log_bin_trust_function_creators = 1;

Last completedCodeAs follows:

Code

  Create  Definer  =     CURRENT_USER     Function  'Func _ get_city_name '('cid'  Int  )
Returns Varchar ( 50 )
Begin
Declare Result Varchar ( 50 );
Set Result = '' ;
Select Region_name Into Result From Vsvt_region Where Region_id = CID;
Return Result;
End ;;

 

 

Related Article

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.