USP_DATALIST_PDACCOUNTSTRUCTURE

Returns a list of account structure elements.

Definition

Copy


CREATE procedure dbo.USP_DATALIST_PDACCOUNTSTRUCTURE
as
    set nocount on;
  declare @HasAccounts nchar(1) = cast(dbo.UFN_PDACCOUNTSTRUCTURE_ACCOUNTEXISTS()as NCHAR(1))
  declare @HasTransactions nchar(1)

  if exists (select * from dbo.GLTRANSACTION where GLACCOUNTID is not null and GLACCOUNTID in (select ID from dbo.GLACCOUNT where PDACCOUNTSYSTEMID = '4B121C2C-CCE6-440D-894C-EA0DEF80D50B'))
    set @HasTransactions = '1'
  else
    set @HasTransactions = '0'

    select 
        ID,
        DESCRIPTION, 
        SEQUENCE
        LENGTH
        (SELECT FRIENDLYTABLENAME FROM DBO.PDACCOUNTTABLESAVAILABLEFORSEGMENT WHERE ID = PDACCOUNTSTRUCTURE.PDACCOUNTTABLESAVAILABLEFORSEGMENTID) TABLENAME,        
        --cast(dbo.UFN_PDACCOUNTSTRUCTURE_ACCOUNTEXISTS()as NCHAR(1)) HASACCOUNTS,

    @HasAccounts HASACCOUNTS,
        case PDACCOUNTSTRUCTURE.SEGMENTTYPE when 2 then '1' when 3 then '1' when 4 then '1' else '0' end HASMAPPING,                
        SEPARATOR,
    @HasTransactions HASTRANSACTIONS
    from dbo.PDACCOUNTSTRUCTURE 
    where PDACCOUNTSYSTEMID = '4B121C2C-CCE6-440D-894C-EA0DEF80D50B'
    order by sequence