USP_DATALIST_PDACCOUNTSTRUCTURE2

Returns a list of account structure elements.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the context ID for the data list.

Definition

Copy


CREATE procedure dbo.USP_DATALIST_PDACCOUNTSTRUCTURE2(@ID uniqueidentifier)
    as
        set nocount on;
        declare @HasAccounts nchar(1)
        declare @HasTransactions nchar(1)

        if exists (select 1 from dbo.GLACCOUNT where PDACCOUNTSYSTEMID = @ID)
        begin
            set @HasAccounts = '1'
            set @HasTransactions = '1'
        end
        else
        begin
            set @HasAccounts = '0' 
            set @HasTransactions = '0'
        end

        select 
            PDACCOUNTSTRUCTURE.ID,
            PDACCOUNTSTRUCTURE.DESCRIPTION, 
            PDACCOUNTSTRUCTURE.SEQUENCE
            PDACCOUNTSTRUCTURE.LENGTH
            PDACCOUNTTABLESAVAILABLEFORSEGMENT.FRIENDLYTABLENAME as TABLENAME,        
            @HasAccounts HASACCOUNTS,
            case PDACCOUNTSTRUCTURE.SEGMENTTYPE when 2 then '1' when 3 then '1' when 4 then '1' else '0' end HASMAPPING,                
            PDACCOUNTSTRUCTURE.SEPARATOR,
        @HasTransactions HASTRANSACTIONS,
            PDACCOUNTSTRUCTURE.ISPROJECTSEGMENT 
        from dbo.PDACCOUNTSTRUCTURE
        left join dbo.PDACCOUNTTABLESAVAILABLEFORSEGMENT on PDACCOUNTTABLESAVAILABLEFORSEGMENT.ID = PDACCOUNTSTRUCTURE.PDACCOUNTTABLESAVAILABLEFORSEGMENTID
        where PDACCOUNTSTRUCTURE.PDACCOUNTSYSTEMID = @ID 
        order by sequence