MySQL Error handling

Source: Internet
Author: User
Tags error handling

there are several declarative forms of error handling: § If any errors (not notFOUND), set L_error to1to continue execution after:DECLARE CONTINUEHANDLER forSQLEXCEPTIONSETL_error=1§ If any errors occur (not notFOUND), executes rollback and generates an error message after exiting the current block or stored procedure. DECLARE EXITHANDLER forSQLEXCEPTIONBEGIN ROLLBACK; SELECT 'Error occurred–terminating'; END§ If the MySQL 1062 error (Duplicate health value) occurs, execute the SELECT statement (sending a message to the caller) after executionDECLARE CONTINUEHander for 1062 SELECT 'Duplicate key in index'§ If the SQLSTATE 2300 error (Duplicate health value) occurs, execute the SELECT statement (sending a message to the calling program)DECLARE CONTINUEHander forSQLSTATE'23000' SELECT 'Duplicate key in index'§ When the cursor or SQL SELECT statement does not return a value, set the L_done=1continue execution afterDECLARE CONTINUEHANDLER for  notFOUNDSETL_done=1This example, in addition to using the SQLSTATE variable instead of a naming condition, is the same as in the previous exampleDECLARE CONTINUEHANDLER forSQLSTATE'02000' SETL_done=1in this example, in addition to using MySQL's error code variables instead of naming conditions or SQLSTATE variables, the first two examplesDECLARE CONTINUEHANDLER for 1329 SETL_done=1;

MySQL Error handling

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.