我如何在存储过程中抛出异常?例如:
@temp int =0
As
BEGIN
SELECT @int = COUNT(*) FROM TABLE1
END
IF(@temp>0)
throw SQL Exception
附言:不使用返回值
我如何在存储过程中抛出异常?例如:
@temp int =0
As
BEGIN
SELECT @int = COUNT(*) FROM TABLE1
END
IF(@temp>0)
throw SQL Exception
附言:不使用返回值
severity >=16
是什么意思? - Zameer AnsariDELIMITER $$
CREATE PROCEDURE throw_exception (IN param1 INTEGER)
BEGIN
DECLARE testvar INTEGER;
SELECT testfield INTO testvar FROM atable WHERE id = param1 LIMIT 1;
IF testfield IS NULL THEN
/*throw the error here*/
SELECT * FROM
error_testfield_in_atable_not_found_youve_entred_a_nonexisting_id_in_throw_exception;
END IF;
END $$
DELIMITER ;