Re: Limit the levels for a query with CONNECT BY

From: Bernard Drolet <le_pul_at_yahoo.ca>
Date: 6 Nov 2003 15:19:45 -0800
Message-ID: <ee7856eb.0311061519.152dc07e_at_posting.google.com>


I found my solution. To stop connecting after I found my required levels of rows, I added the following condition in my query (I'm looking down to a row named XYZ, and I do not want to go further):

SELECT
  id
FROM
  MyTable
WHERE
  name = 'XYZ'
START WITH id = 1
CONNECT BY parentid = PRIOR id AND

PRIOR name != 'XYZ'                   -- THIS SOLVES THE PROBLEM !


So it will never accept to go further than my level with name 'XYZ'

I must admit I was not aware the CONNECT BY could be used with a condition more complex than just the tree structure. I shall read better the documentation next time.

Thank you all

Bernard Drolet Received on Fri Nov 07 2003 - 00:19:45 CET

Original text of this message