[dbo].[EnqueueXmlSystemTransferrals]
create procedure [dbo].[EnqueueXmlSystemTransferrals]
@inXmlSystemId int,
@inSysUserId int,
@inOrderId int
as
set nocount on
if exists
(
select top 1 1
from XmlSystemTransfer
where XmlSystemFid = @inXmlSystemId
)
begin
declare @theUploadRequestTypeId int
select @theUploadRequestTypeId = XmlSystemRequestTypeId from XmlSystemRequestType where [Name] = 'Upload'
declare @theQueuedXmlSystemRequestStatusId int
select @theQueuedXmlSystemRequestStatusId = XmlSystemRequestStatusId from XmlSystemRequestStatus where [Name] = 'Queued'
insert into XmlSystemRequestQueue
(
XmlSystemDataTypeMapFid,
XmlSystemRequestTypeFid,
OrderFid,
SysUserFid,
XmlSystemRequestStatusFid
)
select
XmlSystemTransfer.XmlSystemDataTypeMapFid,
@theUploadRequestTypeId,
@inOrderId,
@inSysUserId,
@theQueuedXmlSystemRequestStatusId
from XmlSystemTransfer
left outer join XmlSystemRequestQueue as ExistingXmlSystemRequestQueue on
ExistingXmlSystemRequestQueue.XmlSystemDataTypeMapFid = XmlSystemTransfer.XmlSystemDataTypeMapFid and
ExistingXmlSystemRequestQueue.OrderFid = @inOrderId and
ExistingXmlSystemRequestQueue.XmlSystemRequestTypeFid = @theUploadRequestTypeId
where
XmlSystemTransfer.XmlSystemFid = @inXmlSystemId and
ExistingXmlSystemRequestQueue.XmlSystemRequestQueueId is null
end
GO
GRANT EXECUTE ON [dbo].[EnqueueXmlSystemTransferrals] TO [MssExec]
GO