
[dbo].[BATGetXLedgerXglsForAllOrders]
create procedure [dbo].[BATGetXLedgerXglsForAllOrders]
@inBatSessionID varchar(50),
@inErrorLoggingSessionId varchar(50),
@inIsStorageProcessing bit = null
as
set nocount on
declare @theCounter int
select @theCounter = 1
declare @theOrderCount int
declare @theCurrentOrderId int
declare @theDistinctOrderIds table( OrderFid int, RowNumber int )
insert into @theDistinctOrderIds
(
OrderFid,
RowNumber
)
select distinct
OrdPriKey as OrderFid,
row_number() over (order by OrdPriKey) as RowNumber
from BATProcess
where
BATSessionID = @inBatSessionID
group by OrdPriKey
select @theOrderCount = max( RowNumber ) from @theDistinctOrderIds
while( @theCounter <= @theOrderCount )
begin
select @theCurrentOrderId = OrderFid from @theDistinctOrderIds where RowNumber = @theCounter
exec spBATGetXLedgerXgls
@inOrderID = @theCurrentOrderId,
@inBatSessionID = @inBatSessionID,
@inErrorLoggingSessionId = @inErrorLoggingSessionId,
@inBatProcessPriKey = null,
@inIsStorageProcessing = 0
set @theCounter = @theCounter + 1
end
GO
GRANT EXECUTE ON [dbo].[BATGetXLedgerXglsForAllOrders] TO [MssExec]
GO