Stored Procedures [dbo].[XmlExportOfficeIndustrialInformation]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)Direction
@inOrderIDint4
@inXmlInterfaceIDint4
@outStatusCodeint4Out
@outErrorCodeint4Out
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/**
*    
*    This procedure is called to generate the xml segment for office & industrial
*    information for the given order.
*    
*    Possible Error Codes:
*    @ERROR_CODE_INVALID_ORDER
*    
*    @param @inOrderID The primary key of a MoversSuite Orders record.
*    @param @inXmlInterfaceID The primary key of a XmlInterface record.
*    @param @outStatusCode Returns whether or not an error occurred while executing this stored procedure.
*    @param @outErrorCode Returns any errors encountered while executing this stored procedure.
*/

CREATE PROCEDURE [dbo].[XmlExportOfficeIndustrialInformation]
    @inOrderID int,
    @inXmlInterfaceID int,
    @outStatusCode int output,
    @outErrorCode int output
as
set nocount on;

-- Initialize the output parameters.
set @outStatusCode    = 0;
set @outErrorCode    = 0;

-- Define the error codes.
declare @ERROR_CODE_INVALID_ORDER    int;
set        @ERROR_CODE_INVALID_ORDER    = 2048;

-- Define the status codes.
declare @STATUS_CODE_PROCESSED    int;
set        @STATUS_CODE_PROCESSED    = 1;
declare @STATUS_CODE_ERROR        int;
set        @STATUS_CODE_ERROR        = 0;

-- Check the order.
declare @theValidOrderFlag bit;
exec    @theValidOrderFlag = dbo.ValidateOrderID @inOrderID;

-- If the order is not valid, return error code @ERROR_CODE_INVALID_ORDER.
if ( 0 = @theValidOrderFlag )
begin
    set @outErrorCode  = @ERROR_CODE_INVALID_ORDER;
    set @outStatusCode = @STATUS_CODE_ERROR;
end
-- Otherwise return the xml segment and set the
-- status code to @STATUS_CODE_PROCESSED.
else
begin
    
    -- Get the office industrial order information
    select
        1         as tag,
        null     as parent,
        [OrderOfficeIndustrialInfo!1!ProjectManager!element]        = dbo.FormatFirstNameLastName( ProjectManagerSysuser.FIRSTNAME, ProjectManagerSysuser.LASTNAME ),
        [OrderOfficeIndustrialInfo!1!JobStartDate!element]        = OfficeIndustrialOrder.JobStartDate,
        [OrderOfficeIndustrialInfo!1!JobEndDate!element]        = OfficeIndustrialOrder.JobEndDate,
        [OrderOfficeIndustrialInfo!1!HeadCount!element]    = OfficeIndustrialOrder.HeadCount,
        [OrderOfficeIndustrialInfo!1!ClientNote!element]    = OfficeIndustrialOrder.ClientNote,
        [OrderOfficeIndustrialInfo!1!OperationalNote!element]    = OfficeIndustrialOrder.OperationalNote
    from OfficeIndustrialOrder
    left outer join Sysuser as ProjectManagerSysuser on ( ProjectManagerSysuser.SysUserID = OfficeIndustrialOrder.ProjectManager )
    where OfficeIndustrialOrder.OrderFID = @inOrderID
    for xml explicit;
    
    set @outStatusCode = @STATUS_CODE_PROCESSED;
end
GO
GRANT EXECUTE ON  [dbo].[XmlExportOfficeIndustrialInformation] TO [MssExec]
GO
Uses