Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: A tale of two tables (and recursive SQL)

RE: A tale of two tables (and recursive SQL)

From: Jesse, Rich <Rich.Jesse_at_qtiworld.com>
Date: Thu, 13 Dec 2001 15:10:39 -0800
Message-ID: <F001.003DC451.20011213143525@fatcity.com>

Doh! A bit of confusion as I re-read my own post. The line:

"don't want hierarchies in T2 whose "assembly" in T1 has "some_flag" set.
In"

has the tables reversed and *should* read:

"don't want hierarchies in T1 whose "assembly" in T2 has "some_flag" set.
In"

<blush>

Rich Jesse                          System/Database Administrator
Rich.Jesse_at_qtiworld.com             Quad/Tech International, Sussex, WI USA


-----Original Message-----
Sent: Thursday, December 13, 2001 15:55
To: Multiple recipients of list ORACLE-L

Hey all,

In 8.1.7.2 on HP/UX, a developer has tables T1 and T2 in our manufacturing (ERP) DB. T1 is a hierarchical bill-of-materials ("BOM") and T2 is the part master. Of course, we need to recurse down T1, like this:

        SELECT LEVEL, assembly, component, qty
        FROM T1
        START WITH assembly = 'ASSY01'
        CONNECT BY PRIOR component = assembly;

...which works great to get us the exploded BOM. The problem is that we don't want hierarchies in T2 whose "assembly" in T1 has "some_flag" set. In syntactically-incorrect code, we want;

        SELECT LEVEL, assembly, component, qty
        FROM T1
        START WITH assembly = 'ASSY01'
        CONNECT BY PRIOR component = assembly
        AND PRIOR component =
                (SELECT partno
                FROM T2
                WHERE partno = PRIOR component
                AND some_flag = 'Y')

The problem, of course, is that I can't connect the PRIOR component to a table in the subquery.

Anyone have an idea? I can't move that subquery to be outside of the CONNECT BY SELECT because the entire hierarchy below the component whose
"some_flag" != 'Y' needs to be ignored (i.e. subcomponents at lower levels
may have this flag set to 'Y', but because the parent's was not, we don't want the subcomponents, either).

TIA!

Rich Jesse                          System/Database Administrator
Rich.Jesse_at_qtiworld.com             Quad/Tech International, Sussex, WI USA
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jesse, Rich
  INET: Rich.Jesse_at_qtiworld.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Dec 13 2001 - 17:10:39 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US