JDBC and use of SQL CONNECT BY and PRIOR for hierachy (son,father) I want to have the hierarchy of an object. the schema of my table is : HIERARCHY with column SON and column FATHER person father father grandfather my request SQL (on Oracle) is this : SELECT SON FROM HIERACHY START WITH (SON = ?) CONNECT BY A = PRIOR FATHER an exemple of the execution with SON=person is this: person father grandfather but when i execute the request with JDBC,i have juste the first row: person the code is: prepareStatement.setString(1,"person"); resultatRqt = prepareStatement.executeQuery(); resultSet.next(); ->true resultSet.next(); ->false i become mad ;-). thanks to help me. ps:i use the driver Oracle classes12.zip
I use the same type of SQL here at work. We have an EMPLOYEE table with emp_id as the primary key and sup_emp_id as a column which identifies the employees' supervisor, which is very similiar to a son and father relationship. However, when we search the hierarchy, we always start from the supervisor and search downward. This basically gets all employees that reside within the reporting structure for a given supervisor. In our case, we start from the top of a hierarchy, which is the reverse, I believe, to what you are performing because you are starting with a leaf and getting the hierarchy in reverse, but the concept is still the same. Here is the query we use. I'm sure you can adjust it to work in the context of your problem.