识别cmd中的错误
delimiter // create PROCEDURE p5( OUT p_return_code tinyint ) BEGIN declare exit handler for sqlexception BEGIN set p_return_code = 1; rollback; END; DECLARE exit handler for sqlwarning BEGIN set p_return_code = 2; rollback; END; START TRANSACTION; DELETE from tb1; #执行失败 insert into blog(name,sub_time) values('yyy',now()); COMMIT; -- SUCCESS set p_return_code = 0; #0代表执行成功 END // delimiter ;
触发器的语法
delimiter //
create
trigger trigger_name
trigger_time trigger_event
on tbl_name for each row
trigger_body
delimiter ;
流程控制:
if:
if 条件 then
elseif 条件 then
else
end if
while :
while 条件 do
end while