If you have friends who have used vs2005 development tools or other statements such as try catch block in JS, can you have sqlserver's @ error variable in MySQL, or, what about the try catch syntax in C?
The answer is yes, instanceCodeAs follows:
Drop procedure if exists sp_call_jobs;
Create procedure sp_call_jobs ()
Not deterministic
SQL Security definer
Comment''
Begin
Declare _ 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;
End while;
Select _ count;
End;
Statement:
Declare continue handler for sqlexception, sqlwarning, not found SET _ err = 1;
When an sqlexception, sqlwarning, and 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