我有一个可以插入或更新到另一个表的触发器。
在我添加更新之前,触发器正常运行,在我添加更新后,出现错误
当选择列表中只能指定一个表达式时 子查询不是用EXISTS引入的。
你能帮我解决这个问题吗?
UPDATE
OLT_Balance_Update
SET
StartOfDayBalance =
(SELECT dbo.OLT_Cash_Posting.ClientNo,
ROUND(dbo.OLT_ArAp.NetArAp, 0) + ISNULL(dbo.OLT_Cash_Posting.Amount, 0) + ISNULL(dbo.interface_rlf_deposits.PortoQuantity * dbo.interface_rlf_deposits.PortoAverage, 0) + ISNULL(dbo.OLT_ArAp.InvestorBAC, 0) AS StartOfDayBalance
FROM dbo.OLT_Cash_Posting
LEFT OUTER JOIN dbo.OLT_Client ON dbo.OLT_Cash_Posting.ClientNo = dbo.OLT_Client.ClientNo
LEFT OUTER JOIN dbo.OLT_ArAp ON dbo.OLT_Cash_Posting.clientno = dbo.OLT_ArAp.ClAcNo
LEFT OUTER JOIN dbo.interface_rlf_deposits ON dbo.OLT_Client.ClientNo = dbo.interface_rlf_deposits.clAcno)
WHERE
Clientno IN (SELECT P.ClientNo
FROM OLT_Balance_Update P, inserted I
WHERE P.ClientNo = I.ClientNo)
答案 0 :(得分:0)
试试这个:
针对SET StartOfDayBalance语句返回的多个值
UPDATE OLT_Balance_Update
SET StartOfDayBalance = ROUND(dbo.OLT_ArAp.NetArAp, 0) + ISNULL(dbo.OLT_Cash_Posting.Amount, 0) + ISNULL(dbo.interface_rlf_deposits.PortoQuantity * dbo.interface_rlf_deposits.PortoAverage, 0) + ISNULL(dbo.OLT_ArAp.InvestorBAC, 0)
FROM dbo.OLT_Cash_Posting
LEFT OUTER JOIN dbo.OLT_Client
ON dbo.OLT_Cash_Posting.ClientNo = dbo.OLT_Client.ClientNo
LEFT OUTER JOIN dbo.OLT_ArAp
ON dbo.OLT_Cash_Posting.clientno = dbo.OLT_ArAp.ClAcNo
LEFT OUTER JOIN dbo.interface_rlf_deposits
ON dbo.OLT_Client.ClientNo = dbo.interface_rlf_deposits.clAcno
WHERE Clientno IN
(SELECT P.ClientNo FROM OLT_Balance_Update P join inserted I on P.ClientNo = I.ClientNo)