开发者

Power error handling inside of sql function

I have a power function call inside of a sql function. What is the correct way to handle overflow and under开发者_如何学编程flow conditions since I cannot use a Try Catch inside of a function. I am also trying to avoid modifying the ARITHABORT, ANSI_WARNINGS, and ARITHIGNORE settings in the calling code.

GO

CREATE FUNCTION TestPow()
RETURNS DECIMAL(30, 14)
AS
BEGIN
    DECLARE @result FLOAT
    SET @result = POWER(10.0, 300)
    RETURN @result
END

GO

SELECT dbo.TestPow()


Use a stored procedure with an output parameter instead, that way you can use proper error handling

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜