473,654 Members | 3,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get the complete list of child tables and their child tables and so on...

Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F

Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.

Thanks

May 30 '07 #1
3 2091
am***********@g mail.com wrote:
Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F

Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.
You need to write a recursive query over SYSCAT.REFERENC ES.

Enjoy
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 30 '07 #2
On May 30, 5:32 pm, Serge Rielau <srie...@ca.ibm .comwrote:
amitabh.me...@g mail.com wrote:
Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F
Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.

You need to write a recursive query over SYSCAT.REFERENC ES.

Enjoy
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Can someone help me formulate this query?

May 30 '07 #3
am***********@g mail.com wrote:
On May 30, 5:32 pm, Serge Rielau <srie...@ca.ibm .comwrote:
>amitabh.me...@ gmail.com wrote:
>>Suppose I have the following scheam (parent->child) :
A->B->C->D, E->F
Can someone help me with the sql query in db2 which will give me the
complete chain once i give it the parent table. eg. for input A, i
should get B, C, D and for input E it should give me F.
You need to write a recursive query over SYSCAT.REFERENC ES.
Can someone help me formulate this query?
Download my "SQL on Fire" talk from here:
http://www.iiug.org/waiug/present/Fo...Forum2006.html
It explains recursion and has an example.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
19786
by: maricel | last post by:
Is there a way to list (using db2 command or catalogs) to list hierarchy of table parent & child relationship: 1) A list that shows which table should be deleted first,second,third... 2) A list that shows which table should loaded first, second,third... Your help would be highly appreciated. maricel.
5
4328
by: Ilan Sebba | last post by:
When it comes to adding records in related tables, Access is really smart. But when I try to do the same using ADO, I am really stupid. Say I have two parent tables (eg Course, Student) and one child table (StudentProgress). The course progress records how a student progresses on a course. I have one course (History) and one student called Maya. I now want to record her grade (64). If I do this in Access using a form, then the form...
1
2858
by: Bartje | last post by:
Hey, I am wondering what the best solution will be to program the following problem in access, the dutch 97 edition. I am developing a database for a day care centre (for my girlfriend). This database consist out of six tables, Child, Employee, Group, ChildByGroup, EmployeeByGroup (it must be possible to place a child or an employee in more then 1 group) and GroupSort (this table gives some information about the different kind of...
7
1998
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. Currently, I am allowing the parent to be edited by itself. In order to get to a child table, a user needs to select a specific parent table ID. I have set this up using panels, and putting a drop-down list in the first panel, with its contents...
5
3531
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. When I step through the records for the child table the one I would expect to be changed has a row...
1
2700
by: Dave | last post by:
Hi all, My question is: How do you obtain a complete list of all the users that are registered on the local machine? I've been trying for hours now and can't find anything that will help on the groups. Anyone have any idea how to do this in VB.NET? thanks
1
1584
by: sparks | last post by:
I have a main table with teacher names and students I can put this in a subform and filter by teacher name so I have a list of her students in a sub form. the problem I have is this is created in tblmain but now I need to have them enter data each day for each student so I have a new table tbldata that has TimeStart, TimeEnd how can I make a list of students in a subform like I have now created from tblmain, and filtered(so far so...
8
5965
by: Rick | last post by:
VS 2005 I' m setting up a parent/child datagridviews in a form. I am doing a lot of this by hand coding in order to get the feel of things. I want a change in the parent table to trigger a change in the child. Where is the best place (if I cannot set it up to be automatic through relationships) to catch the change in the parent to refetch the child rows?
5
2175
by: shapper | last post by:
Hello, I have the following list: <ul id="parent" class="parent"> <li> <img... </li> <ul id="child" class="child"> <li>Message 1</li>
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.