From oracle-l-bounce@freelists.org  Thu Sep  9 14:45:35 2004
Return-Path: <oracle-l-bounce@freelists.org>
Received: from air189.startdedicated.com (root@localhost)
 by orafaq.com (8.11.6/8.11.6) with ESMTP id i89JjZM16792
 for <oracle-l@orafaq.com>; Thu, 9 Sep 2004 14:45:35 -0500
X-ClientAddr: 206.53.239.180
Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180])
 by air189.startdedicated.com (8.11.6/8.11.6) with ESMTP id i89JjYI16787
 for <oracle-l@orafaq.com>; Thu, 9 Sep 2004 14:45:35 -0500
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP
 id 47DD572D16B; Thu,  9 Sep 2004 14:46:58 -0500 (EST)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
 id 10279-64; Thu,  9 Sep 2004 14:46:58 -0500 (EST)
Received: from turing (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP
 id A659572C638; Thu,  9 Sep 2004 14:46:57 -0500 (EST)
X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1
content-class: urn:content-classes:message
MIME-Version: 1.0
Content-type: text/plain
Subject: RE: writing "recursive SQL"
Date: Thu, 9 Sep 2004 12:49:04 -0700
Message-ID: <B5C5F99D765BB744B54FFDF35F60262109F87A15@irvmbxw02>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: writing "recursive SQL"
Thread-Index: AcSWo6ZTND2lqmW4TxCgvRMtMCbN9gAAfoaQ
From: "Jacques Kilchoer" <Jacques.Kilchoer@quest.com>
To: <susanzlam@yahoo.com>, <oracle-l@freelists.org>
X-OriginalArrivalTime: 09 Sep 2004 19:49:51.0230 (UTC) FILETIME=[2B8831E0:01C496A6]
Content-Transfer-Encoding: 8bit
X-archive-position: 9332
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-To: oracle-l-bounce@freelists.org
X-original-sender: Jacques.Kilchoer@quest.com
Precedence: normal
Reply-To: Jacques.Kilchoer@quest.com
X-list: oracle-l
X-Virus-Scanned: by amavisd-new at freelists.org

SQL> select * from mytable ;
        A         B
--------- ---------
        1         2
        2         3
        3         4
        4         5
        5         6
        0         7
        7         8
        8         9
8 ligne(s) sélectionnée(s).
SQL> select b
  2   from mytable
  3   connect by prior b = a
  4   start with a = 3 ;
        B
---------
        4
        5
        6

SQL> select b
  2   from mytable
  3   connect by prior b = a
  4   start with a = 7 ;
        B
---------
        8
        9
SQL> 

-----Original Message-----
From: oracle-l-bounce@freelists.org [mailto:oracle-l-bounce@freelists.org] On Behalf Of susan lam
...
SQL> select * from mytable;
        A          B
---------- ----------
         1          2
         2          3
         3          4
         4          5
         5          6
         0          7
         7          8
         8          9

8 rows selected.

If A=3, output the corresponding value of B (ie 4),
then match B (ie 4) with A and output the next
corresponding value of B (ie 5) and so on... 
Recursion stops when B != A

A & B are unqiue and A=<value> is a user input value

The result I'm looking for is:

if A=3, then the output is:
4
5
6

if A=7, then the output is:
8
9

...


--
To unsubscribe - mailto:oracle-l-request@freelists.org&subject=unsubscribe 
To search the archives - http://www.freelists.org/archives/oracle-l/

