Here is the situation:
I have a property table with various information. This table has a prop_id that identifies each individual property. The table also has a field named prop_orig_id that is a foreign key to the prop_id field of the same table. Therefore, it is a unary relationship.
A property can be a child of another property. And a child can have children.
Example:
PROP_ID | PROP_DSC | PROP_ORIG_ID
----------------------------------------
10 | Property 10 |
11 | Property 11 | 10
12 | Property 12 | 11
13 | Property 13 |
14 | Property 14 | 12
15 | Property 15 |
----------------------------------------
I need to be able to select all the property records for property 10 including it's child records and their child records and so forth.
My result set should be (if wanted prop_id and prop_dsc):
--------------------
10 |
11 | Property 11
12 | Property 12
14 | Property 14
--------------------
I am using DB2 7. Is this possible? Currently it is being done with a recursive function calling the db over and over again.
Thanks, Brinson
I have a property table with various information. This table has a prop_id that identifies each individual property. The table also has a field named prop_orig_id that is a foreign key to the prop_id field of the same table. Therefore, it is a unary relationship.
A property can be a child of another property. And a child can have children.
Example:
PROP_ID | PROP_DSC | PROP_ORIG_ID
----------------------------------------
10 | Property 10 |
11 | Property 11 | 10
12 | Property 12 | 11
13 | Property 13 |
14 | Property 14 | 12
15 | Property 15 |
----------------------------------------
I need to be able to select all the property records for property 10 including it's child records and their child records and so forth.
My result set should be (if wanted prop_id and prop_dsc):
--------------------
10 |
11 | Property 11
12 | Property 12
14 | Property 14
--------------------
I am using DB2 7. Is this possible? Currently it is being done with a recursive function calling the db over and over again.
Thanks, Brinson