Question

I have prepared few queries using startwith and connectby for fetching all items of a table with parent - childs relationship.

Till now, these queries were working perfectly fine. But now, i noticed the hierarchy returned was not the same. hierarchy is returned in totally random way, although the data is same.

Can anyone suggest why this is happening..

Below is the sample query:

SELECT id,loc.title Title FROM 
(SELECT level level,id id,parent_id Parent_Id,sort_order FROM table1 
START WITH parent_id=0 
CONNECT BY prior id  = parent_id ORDER SIBLINGS BY sort_order) 
INNER JOIN table2 loc ON id = loc.id WHERE loc.locale=?
Was it helpful?

Solution

the ORDER SIBLINGS BY will do what you want if you don't wrap the query as an inline view.

once you wrap it, then the ordering is no longer specified

i would suggest doing the JOIN directly in the inner query.. then your order by should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top