I have problem that I think is only solvable with a Connect-to-prior statement.
My data model is, simplified, as follows:
create table TASK
( TASK_ID number
);
create table ITEM
( TASK_ID number,
NEXT_TASK_ID number
);
create table TASK_ITEM
( TASK_ID number,
ITEM_ID number
);
a set of items are combined into a task. A set for tasks are combined into one or more items (this is where the TASK_ITEM junction-table comes in). The process starts with a set of items, and ends with a single item (ITEM.NEXT_TASK_ID is null for the last item, and no task_item's exist for the first items).
My problem:
Given one task_id I want to extract all preceding tasks.
This is a problem bordering on those described in Philip Greenspun's excellent introduction to trees in Oracle, or in Wikibook's description of Hierarchical Queries, but can't seem to find any good solutions tackling these problems when they include more ID's and a Junction table.
My own SQL-foo falls sadly short, and I've googled my heart out without finding a solution to my particular problem.
In the voice of Carrie Fisher: Help me Stack Overflow, you're my only hope.