How to capture exceptions in MySql

Source: Internet
Author: User
Can mySql have the SQLserver @ error variable, or the trycatch syntax in c. MySQL catch exceptions ** does mySql have the @ error variable of SQLserver, or the trycatch syntax in c. The answer is yes. The instance code is as follows: ** CodeDROPPROCEDUREIFEXISTSsp_call_jobs; CREATE

Does mySql have the SQLserver @ error variable, or the try catch syntax in c. MySQL exception capture/** does mySql have the @ error variable of SQLserver, or the try catch syntax in c. The answer is yes. The instance code is as follows: **/CodeDROP procedure if exists sp_call_jobs; CREATE

Does mySql have the SQLserver @ error variable, or the try catch syntax in c. MySQL exception capture
/** Does mySql have @'s @ error variable, or the try catch syntax in c. The answer is yes. The instance code is as follows: **/CodeDROP procedure if exists sp_call_jobs; create procedure sp_call_jobs () not deterministic SQL SECURITY DEFINER COMMENT ''BEGINdeclare _ row, _ err, _ count int default 0; declare continue handler for sqlexception, SQLWARNING, not found set _ err = 1; while _ row <3 do start transaction; insert into t1 (cond_val) values (null); COMMIT; if _ err = 1 then set _ count = _ count + 1; end if; set _ row = _ row + 1; en D while; select _ count; END;/** statement: declare continue handler for sqlexception, SQLWARNING, not found set _ err = 1; it is used when SQLEXCEPTION, SQLWARNING, when the not found error occurs, SET _ err = 1 and execute the CONTINUE operation, that is, CONTINUE to execute the following statement. This is similar to the try catch syntax in c. We also use the TRANSACTION statement: start transaction ;...... COMMIT; can ensure integrity. **/

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.