如何从 SQL Server 2005 函数中抛出异常? [英] How to throw exception from SQL server 2005 function?
本文介绍了如何从 SQL Server 2005 函数中抛出异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试使用 RaiseError 时,出现以下编译问题
When I try to use RaiseError, I get the following compilation issue
消息 443,级别 16,状态 14,过程 ConvertSessionToCurr,第 19 行无效使用副作用运算符RAISERROR"功能.
Msg 443, Level 16, State 14, Procedure ConvertSessionToCurr, Line 19 Invalid use of a side-effecting operator 'RAISERROR' within a function.
那么我们如何处理函数中的异常/将其更改为输出参数存储过程?这听起来真的很糟糕!
So how do we handle exception in a function/ Change it to a out param stored proc? That really sounds like a bummer!
推荐答案
选项:
- 返回 NULL 或一些标记值
- 使用存储过程
- 使其成为内联代码
我的想法是,如果您在 UDF 中需要 RAISERROR,那么您使用它是错误的...
My thought is that if you need RAISERROR in a UDF you're using it wrong...
这篇关于如何从 SQL Server 2005 函数中抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文