我想在大查询脚本中使用 RAISE 关键字将自定义消息打印为异常错误。但是,以下命令行在 raise 命令中引发错误。但是,如果我删除 raise 命令,它工作正常。您能帮我如何提出自定义错误消息吗?另外,要了解更多关于RAISE [USING MESSAGE = message];
.
BEGIN
SELECT 1/0; -- attempts to divide by zero
RAISE USING message = "divisible with zero is not allowed.";
EXCEPTION WHEN ERROR THEN
SELECT FORMAT("Hey, you. When you executed %s at %s, it caused an error: %s. Please don't do that.", @@error.statement_text, @@error.formatted_stack_trace, @@error.message);
END;