我收到一个错误
= 附近的语法不正确
执行此过程时:
DECLARE @I_BRANCH_ID VARCHAR(MAX)
EXEC GETBALANCE CASE WHEN @I_BRANCH_ID ='' THEN 0 ELSE @I_BRANCH_ID END
我收到一个错误
= 附近的语法不正确
执行此过程时:
DECLARE @I_BRANCH_ID VARCHAR(MAX)
EXEC GETBALANCE CASE WHEN @I_BRANCH_ID ='' THEN 0 ELSE @I_BRANCH_ID END
您不能将条件语法放入这样的 EXECUTE 语句中。
相反,请尝试:
IF (@I_BRANCH_ID = '')
SET @I_BRANCH_ID = '0'
EXECUTE GetBalance @I_BRANCH_ID
编辑:
使用更多参数,您可以简化为:
SELECT @param1 = CASE WHEN @param1 = '' THEN '0' ELSE @param1 END,
@param2 = CASE WHEN @param2 = '' THEN '0' ELSE @param2 END,
@param3 = CASE WHEN @param3 = '' THEN '0' ELSE @param3 END
... etc etc
尝试将变量的值与 EXECUTE 语句分开设置:
DECLARE @I_BRANCH_ID VARCHAR(MAX)
SET @I_BRANCH_ID = CASE WHEN @I_BRANCH_ID = '' THEN 0 ELSE @I_BRANCH_ID END
EXEC GETBALANCE @I_BRANCH_ID
DECLARE @I_BRANCH_ID VARCHAR(MAX)
SET @I_BRANCH_ID = CASE WHEN @I_BRANCH_ID = '' THEN '0' ELSE @I_BRANCH_ID END
EXEC GETBALANCE @I_BRANCH_ID