× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



select LEVEL, C1, C2, action
from mytbl
start with C1 = 'ABC'
connect by C1 = prior C2

Charles

On Thu, Aug 30, 2018 at 12:22 PM Charles Wilt <charles.wilt@xxxxxxxxx>
wrote:

Sounds like you want a recursive query (aka recursive common table
expression (v5r4))...

At 7.1 you even have the CONNECT BY clause available to do recursion
without the CTE...

https://www.mcpressonline.com/analytics-cognitive/db2/techtip-db2s-connect-by-simplifies-recursive-processing


Charles

On Thu, Aug 30, 2018 at 11:48 AM Dan <dan27649@xxxxxxxxx> wrote:

Not sure how to explain it better than the subject, but...

Using the sample data table below (best viewed with a fixed font), is
there
a way to have SQL return only the rows marked with an asterisk when I want
the path that begins with 'ABC'? (The asterisk is not part of the data;
it
is just to show the rows I want returned.) The selection needs to follow
the path. C2 indicates that a rename of C1 has taken place. If C2 is
blank, then try to find the next record where the value in the current
record's C1 matches the next record's C1. If C2 is NOT blank, then try to
find the next record where the value in the current record's C2 matches
the
next record's C1. (The Action column isn't particularly important here,
except to show that there is other data in the rows that should be
returned.)

C1 C2 Action
---- ---- ------
AA8X V
ABC C *
S23S C
ABC DEG M *
SDFD WELX V
DEG V *
DEG S *
DEG BRA3 X *
WELX V
BRA3 V *
BRA3 MPX8 W *

- Dan
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.