我收到错误
语法不正确=
执行此程序时:
DECLARE @I_BRANCH_ID VARCHAR(MAX)
EXEC GETBALANCE CASE WHEN @I_BRANCH_ID ='' THEN 0 ELSE @I_BRANCH_ID END
答案 0 :(得分:1)
您不能将条件语法放入这样的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
答案 1 :(得分:0)
尝试与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
答案 2 :(得分:0)
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