sql - MySQL not catching error -


why code not catching error when try delete row doesn't exist? no matter parameter pass in name of row, returns "1 row deleted" , doesn't use exit handlers. supposed catch type of error.

use yoga;  drop procedure if exists delete_warmup;  delimiter //  create procedure delete_warmup  (     warmup_name_param               varchar(100) ) begin declare row_not_found       tinyint default false; declare sql_exception       tinyint default false;  begin     declare exit handler 1329         set row_not_found = true;     declare exit handler sqlexception         set sql_exception = true;      delete warmup     warmup_name = warmup_name_param;      select '1 row deleted.' message; end;  if row_not_found = true     select 'row not deleted - row not found' message; elseif sql_exception = true     show errors; end if;  end//  delimiter ;  call delete_warmup ('monkey business'); 

you using exit handler duplicate parameter: http://www.briandunning.com/errors/596 1329 specified

perhaps should try error code 1011 : http://www.briandunning.com/errors/278

also, try looking not found sqlexception

also, try put exit handler outside begin/end clause.

so begin , end clause

declare exit handler 1011 declare exit handler sqlexception, not found begin         set row_not_found = true;         set sql_exception = true;      delete warmup     warmup_name = warmup_name_param;      select '1 row deleted.' message;  end; 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -