I am not sure why it ends like that - Accounts-Expanded Nodes is an automatic table created during hierarchy load and shoud get auto-dropped, but probably something goes wrong because of the loop. I would first load the whole adjacent node table (via the loop) and then reload it using hierarchy load:
DBS: SELECT DB_Name FROM Configuration; AccountsAdjacent: LET NoOfDBS = NoOfRows('DBS'); FOR i=0 TO $(NoOfDBS)-1 LET DB_Name = peek('DB_Name',$(i),'DBS'); SELECT '$(DB_Name)' AS DB_Name, Acc_Type, Acc_Name, Acc_AccId, Acc_ParId FROM CDN_$(DB_Name).CDN.Accounts; NEXT Accounts: HIERARCHY(Acc_AccId, Acc_ParId, Acc_Name) LOAD * RESIDENT AccountsAdjacent; DROP TABLE AccountsAdjacent;
The Hierarchy prefix makes a transformation that needs the entire Adjacent Nodes table - an output record from this transformation has information from many of the input records. So, concatenation of two different Hierarchy prefix statements will lead to unpredictable results.
So, Kuba's solution is completely right. First, create the entire Adjacent Nodes table, then do the Hierarchy transformation.