这是我的存储过程。在这里,我得到两个百分比的两个id值。我想根据具有该ID百分比的ID列更新acc_cashbook中的列金额。但是这里仅基于一个ID进行更新。我想根据两个ID对其特定的列进行更新。请帮助我。
php artisan make:controller PrurequestsController --resource --model=Usuario2
答案 0 :(得分:0)
我认为问题在于您正在按程序进行思考-如何用简单的代码(而不是基于集合)进行操作。基于对架构的假设,我已尽力对其进行了重新编码。看看这个。现在仅需进行几次基于集合的更新。
还假设仍然需要选择查询,并且它可能从联接中返回多行。如果没有,请删除唯一标识符,或完全删除查询。
ALTER procedure [dbo].[refdocedit]
(@RefDocID int,
@LabNo int)
as
begin
declare @NameOfParty varchar(50)
update LabRegDetail set RefDocId=@RefDocID where LabNo=@LabNo
select @NameOfParty= RefFirstName+''+RefMiddleName+''+RefLastName from RefDocMaster where RefDocID=@RefDocID
select distinct acc.NameOfParty,acc.Voucher_NameOfParty,acc.Amount
from LabRegDetail lrd
join LabPatientTestDetails lptd on lptd.U_labNo=lrd.U_labNo
join Acc_CashBook acc on acc.ID=lptd.ID and acc.Ns_Or_PHM=lptd.TestOrPkg
where lrd.LabNo=@LabNo
update acc set NameOfParty=@NameofParty, Voucher_NameOfParty=@NameOfParty,
Amount=(rdlc.Percentage/100)*lptd.StdAmt
from LabRegDetail lrd
join LabPatientTestDetails lptd on lptd.U_labNo=lrd.U_labNo
join Acc_CashBook acc on acc.ID=lptd.ID and acc.Voucher_PartyType=2
join LabRegDetail lrd on lrd.LabNo=acc.LabNo
join RefDocLabCommission rdlc on lrd.RefDocId=rdlc.RefDocID and rdlc.ID=acc.ID
where lrd.LabNo=@LabNo
update bb set NameOfParty=@NameOfParty,Voucher_NameOfParty=@NameOfParty,
Amount=(rdlc.Percentage/100)*lptd.StdAmt
from LabRegDetail lrd
join LabPatientTestDetails lptd on lptd.U_labNo=lrd.U_labNo
join Acc_CashBook acc on acc.ID=lptd.ID and acc.Voucher_PartyType=2
join LabRegDetail lrd on lrd.LabNo=acc.LabNo
join RefDocLabCommission rdlc on lrd.RefDocId=rdlc.RefDocID and rdlc.ID=acc.ID
join Acc_BankBook b on bb.LabNo=lrd.LabNo and bb.Voucher_PartyType=2
where lrd.LabNo=@LabNo
end