alter proc PRTODA(@SimpraPRNumber nvarchar(20),@SimpraDANumber int)
as
begin
declare @DRID int =0,@PRID int
declare @SOHID int =0,@CustomerID int =0
declare @Quantity int =0
declare @Rate decimal(15,2)=0.0
declare @CustomerIDOld int =0
declare @QuantityOld int =0
declare @RateOld decimal(15,2)=0.0
select @DRID=DRID,@PRID=PRID from prheader where simpraprnumber='CSDS1917492101'
select @SOHID=SOHID from drheader where drid=@DRID
select @CustomerID=CustomerID from soheader where sohid=@SOHID
select @Quantity=SOQuantity,@Rate=BasicRate from soheaderproductdetails where sohid=56115
--select @Rate as Rate,@Quantity as Quantity,@CustomerID as CustomerId
--Old
select @RateOld=BasicRate,@QuantityOld=Quantity,@SOHID=SOHID from dadetails where daid=485996
select @CustomerIDOld=CustomerID from soheader where sohid=@SOHID
--select @RateOld as RateOld,@QuantityOld as QuantityOld,@CustomerIDOld as CustomerIdOld
If(@Rate=@RateOld and @CustomerId=@CustomerIdOld and @Quantity=@QuantityOld)
begin
insert into DADetailsLog select *,GETDATE(),'@DeleteBy' from dadetails where DAID=@SimpraDANumber
update dadetails set PRID=@PRID where DAID=@SimpraDANumber
End
else
select 'invalid'
end
as
begin
declare @DRID int =0,@PRID int
declare @SOHID int =0,@CustomerID int =0
declare @Quantity int =0
declare @Rate decimal(15,2)=0.0
declare @CustomerIDOld int =0
declare @QuantityOld int =0
declare @RateOld decimal(15,2)=0.0
select @DRID=DRID,@PRID=PRID from prheader where simpraprnumber='CSDS1917492101'
select @SOHID=SOHID from drheader where drid=@DRID
select @CustomerID=CustomerID from soheader where sohid=@SOHID
select @Quantity=SOQuantity,@Rate=BasicRate from soheaderproductdetails where sohid=56115
--select @Rate as Rate,@Quantity as Quantity,@CustomerID as CustomerId
--Old
select @RateOld=BasicRate,@QuantityOld=Quantity,@SOHID=SOHID from dadetails where daid=485996
select @CustomerIDOld=CustomerID from soheader where sohid=@SOHID
--select @RateOld as RateOld,@QuantityOld as QuantityOld,@CustomerIDOld as CustomerIdOld
If(@Rate=@RateOld and @CustomerId=@CustomerIdOld and @Quantity=@QuantityOld)
begin
insert into DADetailsLog select *,GETDATE(),'@DeleteBy' from dadetails where DAID=@SimpraDANumber
update dadetails set PRID=@PRID where DAID=@SimpraDANumber
End
else
select 'invalid'
end
No comments:
Post a Comment