aspose file tools
The moose likes JDBC and the fly likes JDBC and use of SQL CONNECT BY and PRIOR for hierachy (son,father) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "JDBC and use of SQL CONNECT BY and PRIOR for hierachy (son,father)" Watch "JDBC and use of SQL CONNECT BY and PRIOR for hierachy (son,father)" New topic
Author

JDBC and use of SQL CONNECT BY and PRIOR for hierachy (son,father)

arnaud pasquer
Greenhorn

Joined: Jun 26, 2003
Posts: 1
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
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
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.

Raffi
[ June 26, 2003: Message edited by: SAFROLE YUTANI ]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JDBC and use of SQL CONNECT BY and PRIOR for hierachy (son,father)
 
Similar Threads
CMP with JBOSS
Network Adapter
servlets and xml
stuck up in the problem
getting access to grandfather's constructor