Stored Procedures [dbo].[EnqueueXmlSystemTransferrals]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inXmlSystemIdint4
@inSysUserIdint4
@inOrderIdint4
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/*
*    Queues the specified order to be uploaded to other Xml System(s) if the specified Xml System is set up to automatically upload
* to other systems (i.e. if there are record(s) in the XmlSystemTransfer table for the specified Xml System).
*
*    @param @inXmlSystemId Primary key of a XmlSystem record - If there are XmlSystemTransfer record(s) for this Xml System,
*        then we queue the order to be uploaded to those Xml System(s).
* @param @inSysUserId Primary key of a SysUser record - this will be saved as the sysuser who queued the order to be uploaded.
* @param @inOrderId Primary key of an Orders record - this is the order that will be uploaded.
*/

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
Uses