DECLARE t_error INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET t_error=1; START TRANSACTION; ......sql ......sql IF t_error = 1 THEN ROLLBACK; select 0; ELSE COMMIT; select 1; END IF;