I’m trying to write a recursive function of sorts in PL/SQL.
The problem is:
So say table A has rows:
{B, C},
{C, D},
{C, F},
{D, E},
{E, F}
Return everything that B is dependent on, directly and indirectly.
The tuple {B, C} implies that B is dependent on C, C is dependent on D and so on and so forth.
This function, when given B, would return a cursor or something that would yield: {C, D, F, E}
Notice that simple looping through and just printing values may yield duplicate results (in this case, E).
I’m rather new to PL/SQL and I can’t really think of a way to do this.
Thanks in advance for any help!
Assuming the table looks like this:
Why wouldn’t you use a hierarchical query like:
This SQL’s untested, but it should be a point in the right direction; your function could return that cursor if that’s what you needed, or an array of values if not.