Stored Procedures [dbo].[XLedgerGetSubmittedHoldChangesBatch]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
create procedure [dbo].[XLedgerGetSubmittedHoldChangesBatch]
as
begin
    set nocount on

    declare @startedAt datetimeoffset = sysdatetimeoffset()

    declare @items IntList

    --top 50 defines our somewhat arbitrary batch size.
    ;with ItemsToUpdate as
    (
        select top(50) XLedgerTransactionHoldSubmissionId, StartedOn
        from XLedgerTransactionHoldSubmission
        where StartedOn is null
        order by XLedgerTransactionHoldSubmissionId asc
    )
    update ItemsToUpdate
        set StartedOn = @startedAt
    output inserted.XLedgerTransactionHoldSubmissionId into @items

    select
    --selecting directly into a tuple, hence the names.
        Item1 = XLedgerTransactionHoldSubmission.XLedgerTransactionHoldSubmissionId,
        Item2 = XLedgerTransactionHoldSubmission.XLedgerSubledgerTransactionDbId,
        Item3 = XLedgerTransactionHoldSubmission.OnHold
    from @items Items
    inner join XLedgerTransactionHoldSubmission on Items.Item = XLedgerTransactionHoldSubmission.XLedgerTransactionHoldSubmissionId
    order by XLedgerTransactionHoldSubmission.XLedgerTransactionHoldSubmissionId asc -- ordering needed for some processing on the C# side
end
GO
GRANT EXECUTE ON  [dbo].[XLedgerGetSubmittedHoldChangesBatch] TO [MssExec]
GO
Uses