UFN_POST_BANKACCOUNTS_TOITEMLISTXML

Return

Return Type
xml

Parameters

Parameter Parameter Type Mode Description
@POSTTOGLPROCESSID uniqueidentifier IN

Definition

Copy


CREATE function dbo.UFN_POST_BANKACCOUNTS_TOITEMLISTXML
(
    @POSTTOGLPROCESSID uniqueidentifier = null
)
returns xml
as begin
    declare @XML xml
    set @XML = (
        select
            F.ID
            ,case when @POSTTOGLPROCESSID is null then 1 else case when F.ID is null then 0 else 1 end end as [INCLUDE]
            ,BA.ID as [BANKACCOUNTID]
            ,NF.NAME as [BANKNAME]
            ,BA.ACCOUNTNAME
            ,BA.ACCOUNTTYPE
            ,BA.PDACCOUNTSYSTEMID
        from dbo.BANKACCOUNT BA
        left join dbo.POSTTOGLPROCESSBANKACCOUNTFILTER F on @POSTTOGLPROCESSID is not null and F.BANKACCOUNTID = BA.ID and F.POSTTOGLPROCESSID = @POSTTOGLPROCESSID
        outer apply dbo.UFN_CONSTITUENT_DISPLAYNAME(BA.BANKID) NF
        where BA.STATUSCODE = 1
        order by BA.ACCOUNTNAME
        for xml raw('ITEM'), type, elements, root('BANKACCOUNTS'), BINARY BASE64
    )
    set @XML = isnull(@XML, '<BANKACCOUNTS></BANKACCOUNTS>')
    return @XML

end