我有一个 SQL 存储过程,用于在队列中获取一批结果。我正在寻找转移到 Sqlite DB,并且想知道如果可能的话我将如何去做。
ALTER PROCEDURE [dbo].[GetNextItemInQueue]
@LockedBy varchar(75)
AS
SET NOCOUNT ON;
declare
@Error int,
@ExitCode int,
@RowCount int,
@PendingStatus varchar(75),
@MinutesBeforeBreakLock int,
@RequestId int,
@BatchSize int
select
@Error = 0,
@ExitCode = 0,
@RowCount = 0,
@PendingStatus = 'Pending',
@MinutesBeforeBreakLock = 1,
@BatchSize = 100
BEGIN TRY
BEGIN TRANSACTION ProcessQueue
UPDATE TOP(@BatchSize) UploadQueue WITH (UPDLOCK, READPAST)
SET
LockedBy = @LockedBy,
LockedTime = GETDATE()
OUTPUT inserted.Id, inserted.LockedTime, inserted.CompletedTime, inserted.RequestType, inserted.RequestedTime, inserted.Status, inserted.LockedBy, inserted.Data
WHERE
STATUS = @PendingStatus
AND (LockedTime IS NULL OR
DateDiff(mi, LockedTime, GetDate()) >= @MinutesBeforeBreakLock)
COMMIT TRANSACTION ProcessQueue
END TRY
BEGIN CATCH
IF XACT_STATE() > 0
ROLLBACK TRANSACTION ProcessQueue;
ELSE IF XACT_STATE() < 0
ROLLBACK TRANSACTION;
END CATCH