cancel
Showing results for 
Search instead for 
Did you mean: 

Heirarchy function in hana sql

0 Kudos

Heirarchy function returns empty set, though data is present in source.

SELECT * FROM HIERARCHY( SOURCE (SELECT "TEAM_ID" as node_id,"REPORTSID" as parent_id,"TEAM_NAME" FROM "abc.TeamStructure") START WHERE "REPORTSID" IS NULL )

Please let me know, is ther any problem in sql.How can i achieveheirarchical functionality.

mfath
Advisor
Advisor
0 Kudos

Are you using WebIDE? Beside the result set being empty - do you see any error message?

Can you please add a SIBLING ORDER BY clause as described in

hierarchy generation

View Entire Topic
mfath
Advisor
Advisor
0 Kudos

Hej Chanikya,

can you please try to run the inner/source query?

SELECT "TEAM_ID" as node_id,"REPORTSID" as parent_id,"TEAM_NAME" FROM "abc.TeamStructure" WHERE "REPORTSID" IS NULL

if this query returns a non-empty result, then the hierarchy result should also be non-empty.

In case you are not aware, the hierarchy developer guide provide some real nice examples.

Regards, Markus

0 Kudos

Hi Fath,

Thanks for the reply. Yes the inner query

"SELECT "TEAM_ID" as node_id,"REPORTSID" as parent_id,"TEAM_NAME" FROM "abc.TeamStructure"

returns result set.

But still the hierarchy result is empty.

0 Kudos

Hi Markus,

Yes I am using WEB IDE, and there are no error messages. The query executed successfully but with empty result set.

And also added SIBLING ORDER BY, but there is no use. Still the situation is same.

0 Kudos

Hi Markus,

Thanks for the quick response. The issue is resolved as the root value of parent id value is string in null. So the heirarchy function not able to find which is the root element. That's why i am getting an empty result set.