Queries on hierarchical data


Hi all

I have it here is the scenerio

The entry like:

power outletnew_outlet
oneb
bc
cd
done
AABB
BBCC
CCAA
lm
mn
xThere
Therex

expected results will be:

oned
bd
cd
AACC
BBCC
ln
mn
xThere
Therex

Please help me on this. I tried with you connect by prior clause but not able to get the exact output.

Thank you very much

I lost the create table statement, but if you create a table "T" with the data that you have posted:

with case_2 as (
  select outlet, new_outlet, connect_by_root(new_outlet) root_outlet
  from t
  start with new_outlet not in (select outlet from t)
  connect by new_outlet = prior outlet
), case_3 as (
  select outlet, new_outlet root_outlet from t
  where outlet < new_outlet
  and (outlet, new_outlet) in (
    select new_outlet, outlet from t
  )
), case_1_start as (
  select outlet, new_outlet from t
  minus
  select outlet, new_outlet from case_2
  minus
  select * from case_3
  minus
  select root_outlet, outlet from case_3
), case_1 as (
  select outlet, min(connect_by_root(new_outlet)) root_outlet
  from case_1_start a
  start with outlet > new_outlet
  connect by nocycle new_outlet = prior outlet
  group by outlet, new_outlet
)
select outlet, root_outlet from case_1
union all
select outlet, root_outlet from case_2
union all
select outlet, root_outlet from case_3
order by 2,1;
OUTLET ROOT_OUTLET
one one
b one
c one
d one
AA AA
BB AA
CC AA
l n
m n
x There

Post edited by: StewAshton - PS. I removed the MAX()... GROUP BY, and then put it back with MIN() because it is necessary if you have cycles in cycles.

Tags: Database

Similar Questions

  • Multiple queries in a data model - Performance?

    Hi experts,

    I created a data model and defined queries 7 (isolated; not connected together). I want to create 7 reports based on queries 7 (for example query1 used in Report1, query2 used into Report2, etc.).

    The consolidation of 7 queries in a data model affect performance? How the BEEP collects data - is only the query used processed, or each time the entire data model?

    Thanks in advance!

    Hello

    According to the data that you want to use in your report.

    In a report, you can use data from more than queries.

    We recommend that you create 1 data model for each report, for a good performance with all applications you need.

    7 queries fetch data slower than 1 query in your data model.

    Kind regards

    Liviu

  • How to remove hierarchical data?

    Hello

    I have a table with hierarchical data. I want to remove the data based on a condition, but maybe that this condition is present only in the upper hierarchy.

    In my example, I have identified by id lines and a changed_by containing the id of the row that has replaced (invalidated) this line. Of these, I want to delete data where descr in end-nodes is 'A '.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    DROP TABLE test_del;
    CREATE TABLE test_del)
    CONSTRAINT pk_del PRIMARY KEY (id)
    id NUMBER
    changed_by NUMBER
    CONSTRAINT fk_del
    REFERENCES test_del (id)
    , descr VARCHAR2 (10)
    )
    /
    INSERT INTO test_del (id, changed_by, descr)
    VALUES (3, NULL, 'A');
    INSERT INTO test_del (id, changed_by, descr)
    VALUES (2,3, 'A');
    INSERT INTO test_del (ID, changed_by, descr)
    VALUES (1, 2, NULL);

    INSERT INTO test_del (id, changed_by, descr)
    VALUES (6, NULL, 'A');
    INSERT INTO test_del (id, changed_by, descr)
    VALUES (5.6, 'A');

    INSERT INTO test_del (id, changed_by, descr)
    VALUES (10, 'B', NULL);
    INSERT INTO test_del (id, changed_by, descr)
    VALUES (9, 10, 'B');
    INSERT INTO test_del (id, changed_by, descr)
    VALUES (8,9, 'B');
    COMMIT;

    SELECT *.
    OF test_del
    CONNECT BY PRIOR ID = changed_by
    START WITH descr = 'A' changed_by AND IS NULL;

    ID CHANGED_BY DESCR
    ---------- ---------- ----------
    3            A
    2 3
    1          2
    6            A
    3 p

    DELETE FROM test_del WHERE the descr = "A";
    ORA-02292: integrity constraint (FE. FK_DEL) violated - book of the foundling

    Of course, I get ORA-02292 in this case, but how can I write a correct statement that deletes the data displayed by the select?

    Concerning

    Marcus

    You must follow the hierarchy:

    DELETE FROM test_del

    WHERE ROWID IN)

    SELECT THE ROWID

    OF test_del

    CONNECT BY PRIOR ID = changed_by

    START WITH descr = "A".

    AND changed_by IS NULL);

  • Filtered hierarchical data - previous available ancestor?

    I'm trying to find a solution to a problem with hierarchical data and the concept of the closest available ancestor – my platform is gr 10, 2 and 11 GR 2.  I give myself a few hierarchical data (in its simplest form it is in the form ID, NAME, PARENT_ID, where of the PARENT_ID since ID links).

    For example:

    with qryData like)

    Select 1 as ID, 'Bert' as NAME, to_number (null) as PARENT_ID from dual union

    Select 2 as ID, 'Brand', 1 double Union

    Select 3 as ID, 'Brenda', 1 double Union

    Select option 4 as ID, 'Mike', 3 double Union

    Select 5 as ID, 'Steve', 4 double Union

    Select 6 as ID, 'John', 2 double Union

    Select 7 as ID, 'Jo', 6 double Union

    Select ID, "Jim", 2 double Union 8

    Select 9 as ID, 'Jane', the double 7

    )

    Select q.*, sys_connect_by_path (ID, ' /') ID_PATH

    of qryData q

    Start by parent_id is null

    Connect ID PARENT_ID = prior

    /

    ID NAME PARENT_ID ID_PATH

    ---------- ------ ---------- ----------------

    1 Bert 1

    2. Mark 1/1/2

    6 Jean 2/1/2/6

    7 Jo 6/1/2/6/7

    Jane 9 7/1/2/6/7/9

    8 Jim 2/1/2/8

    3 Brenda-1/1/3

    4 mike 3/1/3/4

    5 Steve 4/1/3/4/5

    In reality, this data set can be several thousand rows with dozens of levels of nesting, the several nodes to start without parent but especially often filtered, so some arbitrary lines are missing.  When this happens, I need to find the closest available ancestor that appears in the list. "The closest available ancestor" is closest relationship to ancestor in your family tree which still exists in the filtered list found from parent, then upward contuniing to grandparent, great-grandparent... nth grandparent grand until an ancestor is found.


    For example:

    ID NAME PARENT_ID ID_PATH AVAIL_ANCESTOR_ID

    ---------- ------ ---------- ------------- -----------------

    1 Bert 1

    Jean 6 2 1 1/2/6

    Jim 8 2 1 1/2/8

    Jane 9 7 6 1/2/6/7/9

    Brenda 3 1 1 1/3

    Steve 5 4 3 1/3/4/5

    For example.  Who is Steve closest ancestor in the filtered list?

    Steve's family tree is: / Bert/Brenda/Mike/Steve

    Mike (ID = 4) is not in the filtered list, so we move on Brenda, what is.  Brenda, ID = 3, so ANCESTOR_ID = 3

    I have access to the original table, so that can join the list filtered to the full table, I can also ask other columns (such as ROWID, and ROWNUM, LEVEL SYS_CONNECT_ROOT) to be included in the filtered set.  I tried various methods to achieve this, but all seem to be quite poor in performance (the columns ID and PARENT_ID indexed as appropriate) or does not quite give the correct result, such as...

    1. the analysis of the ID_PATH and the treewalking on this basis and to join the list...

    Select distinct CUSTOMER_ID, regexp_substr (ID_PATH, "[^ /] +', 1, level") as ANCESTOR_ID

    of qryData

    connect regexp_substr (ID_PATH, "[^ /] +', 1, level") is not null

    2 anti-assemblage to return to the full list in order to identify the missing elements, then for those treewalking.

    3 write a function that return treewalks.

    It of a difficult problem, so someone can think a solution that works well?  Ideally, I try to find a SQL based solution?

    Hello

    paulzip wrote:

    It is a clever solution!  The only problem I have is that I wouldn't be able to generate "good_id_path" as part of the filtered list, filtering is not done by me and is done once the id_path is generated.  I have to join the most complete list list filtered back to generate, unless there is a tweak to do?

    I see it; You are given connect_by_results (with id_path), and that's what you have to work with, in addition to the original table.

    Here's one way:

    SELECT d.id d.name, d.parent_id, d.id_path

    MIN (a.id) DUNGEON (DENSE_RANK LAST ORDER BY a.id_path) AS avail_ancestor_id

    OF connect_by_results d

    LEFT OUTER JOIN connect_by_results has the d.id_path AS a.id_path. '/%'

    GROUP BY d.id d.name, d.parent_id, d.id_path

    ORDER BY d.id_path

    ;

    The fastest way depends on a lot of things, some may not be known until the moment of execution.  The query above could be better if the number of rows in the result set is small, but you don't know anything else about them (for example, if all have a common ancestor).

  • Hierarchical data, how to aggregate over levels in hierarchical query?

    Hello

    I hope someone can help me.

    I held in a data table ("" what part was built in what other part of when when? "')
    ID parent_id build_in build_out
    1 NULL NULL NULL
    2/1 2010 2012
    3 2 2011 2013
    4 2 2013 NULL

    What are the parts is stored in a separate table.

    Now I want to know when when which part was built in the first level, in the example, I want to know that
    1 was simply a part of 1
    2 was part of 1 between 2010 and 2012
    3 was part of 1 between 2011 and 2012
    4 has never been a part of 1

    I tried several approaches - if there is a fixed number of levels between the types, I am interested I can do using joins and more/less (similarly as some nvl). Unfortunately this is not always the case (some parts appear on several levels).
    If I'm only interested in the parts that are never deleted, I can get by using a style of connect request and get the current configuration. But I can't seem to understand the time connecting part to the high level in such a query, or even filtering absurd combinations (like "4 in 1" in the example above). I could deal with the data recovered outside the database, but I prefer not.

    Is there a way to obtain the hierarchical data with an aggregate (min, max) for all levels?

    What version of Oracle you are on?

    In 11.2.x, you can use the recursive subquery factoring. Something like

    with t (id, parent_id, build_in, build_out) as (
    select 1, null, null, null from dual union all
    select 2, 1, 2010, 2012 from dual union all
    select 3, 2, 2011, 2013 from dual union all
    select 4, 2, 2013, null from dual
    )
    , c1 (root_id, id, parent_id, build_in, build_out) as (
    select id, id, parent_id, 0, 9999
    from t
    where parent_id is null
    union all
    select root_id, t.id, t.parent_id
    , greatest(nvl(t.build_in,0), nvl(b.build_in,0))
    , least(nvl(t.build_out,9999), nvl(b.build_out,9999))
    from c1 b, t
    where b.id = t.parent_id
    )
    select * from c1
    where build_in < build_out
    ;
    ROOT_ID ID    PARENT_ID  BUILD_IN  BUILD_OUT
    ------- ----- ---------- --------- ----------
    1       1                0         9999
    1       2     1          2010      2012
    1       3     2          2011      2012      
    

    With a hierarchical query by using the syntax connection, you could do something like

    select * from (
    select connect_by_root id as root, id
    , greatest(nvl(build_in,0), nvl(prior build_in,0)) as max_in, least(nvl(build_out,9999), nvl(prior build_out,9999)) as min_out
    from t
    start with parent_id is null
    connect by parent_id = prior id
    )
    where max_in < min_out
    ;
    

    but it is not powerful enough. This version compares the dates between a current and previous levels, but the recursive subquery is to compare the dates in the current level for the winners of the comparisons to the previous level. Not sure if it's an important distinction for your needs, however.

    If you are on 11.2 I advise to use the recursive subquery factoring. If this isn't the case, you can try the link by version.

    Kind regards
    Bob

  • Problem (hierarchical data) resolved by using SQL

    Hi I have hierarchical data stored in a table with 3 columns
    Item1, item2, relationship

    relationship column defines if the element1 is parent of item2 or item1 item2 Chile

    I have a fourth column in the same table indicating the entire hierarchy of the family separated by colons;

    example: a1, a2, child then output will be a1:a2.

    I have tried a lot of things to do with a sql but failed and finally did using the recursive function

    Hoping someone can solve the problem in sql

    You will find examples of data to work with as well as the desired result:
    select 'p1' as element1, 'p2' as element2, 'parent' as relationship, 'p1' as output  from dual
    union all
    select 'p2', 'p1', 'child', 'p1:p2' from dual
    union all
    select 'p1', 'p3', 'parent', 'p1' from dual
    union all
    select 'p3', 'p1', 'child', 'p1:p3' from dual
    union all
    select 'p2', 'p4', 'parent', 'p1:p2' from dual
    union all
    select 'p4', 'p2', 'child', 'p1:p2:p4' from dual
    union all
    select 'p2', 'p5', 'parent', 'p1:p2' from dual
    union all
    select 'p5', 'p2', 'child', 'p1:p2:p5' from dual
    union all
    select 'p3', 'p6', 'parent', 'p1:p3' from dual
    union all
    select 'p6', 'p3', 'child', 'p1:p3:p6' from dual
    union all
    select 'p5', 'p7', 'parent', 'p1:p2:p5' from dual
    union all
    select 'p7', 'p5', 'child', 'p1:p2:p5:p7' from dual
    union all
    select 'p5', 'p8', 'parent', 'p1:p2:p5' from dual
    union all
    select 'p8', 'p5', 'child', 'p1:p2:p5:p8' from dual
    union all
    select 'b1', 'b2', 'parent', 'b1' from dual
    union all
    select 'b2', 'b1', 'child', 'b1:b2' from dual
    union all
    select 'b2', 'b3', 'parent', 'b1:b2' from dual
    union all
    select 'b3', 'b2', 'child', 'b1:b2:b3' from dual
    union all
    select 'c1', 'c2', 'parent', 'c1' from dual
    union all
    select 'c2', 'c1', 'child', 'c1:c2' from dual
    union all
    select 'c1', 'c3', 'parent', 'c1' from dual
    union all
    select 'c3', 'c1', 'child', 'c1:c3' from dual
    union all
    select 'c3', 'c5', 'parent', 'c1:c3' from dual
    union all
    select 'c5', 'c3', 'child', 'c1:c3:c5' from dual
    union all
    select 'c3', 'c6', 'parent', 'c1:c3' from dual
    union all
    select 'c6', 'c3', 'child', 'c1:c3:c6' from dual
    union all
    select 'c3', 'c7', 'parent', 'c1:c3' from dual
    union all
    select 'c7', 'c3', 'child', 'c1:c3:c7' from dual
    union all
    select 'a1', null, 'parent', 'a1' from dual
    Kind regards
    Amit

    don't worry, I fixed it...

    with t as(
    select 'p1' as element1, 'p2' as element2, 'parent' as relationship  from dual
    union all
    select 'p2', 'p1', 'child' from dual
    union all
    select 'p1', 'p3', 'parent'from dual
    union all
    select 'p3', 'p1', 'child' from dual
    union all
    select 'p2', 'p4', 'parent' from dual
    union all
    select 'p4', 'p2', 'child' from dual
    union all
    select 'p2', 'p5', 'parent' from dual
    union all
    select 'p5', 'p2', 'child' from dual
    union all
    select 'p3', 'p6', 'parent' from dual
    union all
    select 'p6', 'p3', 'child' from dual
    union all
    select 'p5', 'p7', 'parent' from dual
    union all
    select 'p7', 'p5', 'child' from dual
    union all
    select 'p5', 'p8', 'parent' from dual
    union all
    select 'p8', 'p5', 'child' from dual
    union all
    select 'b1', 'b2', 'parent' from dual
    union all
    select 'b2', 'b1', 'child' from dual
    union all
    select 'b2', 'b3', 'parent' from dual
    union all
    select 'b3', 'b2', 'child' from dual
    union all
    select 'c1', 'c2', 'parent' from dual
    union all
    select 'c2', 'c1', 'child' from dual
    union all
    select 'c1', 'c3', 'parent' from dual
    union all
    select 'c3', 'c1', 'child' from dual
    union all
    select 'c3', 'c5', 'parent' from dual
    union all
    select 'c5', 'c3', 'child' from dual
    union all
    select 'c3', 'c6', 'parent' from dual
    union all
    select 'c6', 'c3', 'child' from dual
    union all
    select 'c3', 'c7', 'parent' from dual
    union all
    select 'c7', 'c3', 'child' from dual
    union all
    select 'a1', null, 'parent' from dual
    ), p as (
    select * from t where relationship='parent')
    ,q as (
    select * from t where relationship='child'
    )
    select element1,element2,relationship,path from (select path,element1,'parent' relationship,element2 from (
    select path,element1,element2,row_number() over (partition by element1,element2 order by length(path) desc) rnum from (
    select ltrim(sys_connect_by_path(element1,':'),':') path,element1,element2 from p connect by prior element2=element1
    )) where rnum=1
    union all
    select path,element1,'child' relationship,element2 from (
    select path,element1,element2,row_number() over (partition by element1,element2 order by length(path) desc) rnum from (
    select ltrim(connect_by_root element2||sys_connect_by_path(element1,':'),':') path,element1,element2 from q connect by prior element1=element2
    )) where rnum=1)
    

    Ravi Kumar

  • Hierarchical data model

    Hello!

    I need to create data model that describes hierarchical data in table t (something like this in sql: select * t log in prior t.id_parent = t.id).

    How to describe with JDeveloper?

    (Then it will be used in the table of the tree)
    JDeveloper 11.1.1.1

    Thank you!

    Simply create an association 1-* t.id to t.parent_id, then create viewLink based on this association.

  • the problem display of hierarchical data on table tree of ADF 11 g

    We try to display hierarchical data tree ADF tabletop.
    our table a (id, parant_id, name) columns and an open relationship between id and id columns adorning it.
    We create module OT, vo and app. Jdev automatically creates connection object and Association.
    In the editor view, drag us and drop our table as a tree of ADF table.
    In table tree aditor rool we add a rool Association name.
    When we launch the application data display incorrectley. For example if the data as

    1 aaa 0
    2 1 BBB
    3 ccc 2
    4 2 ddd

    We want to display the structure of the tree as

    1
    -> 2
    -> 3
    -> 4

    but it shows the possibilities of something like (lines "BOLD" incorrectly) added.


    1
    -> 2
    -> 3
    -> 4
    * 2 *
    -> 3
    -> 4
    * 3 *
    * 4 *


    (We have 10g. But in the table tree 11g have a different configuration. )

    Thank you...

    I think that if you want to limit the list of records shown at the first level of the tree to those without a father - you'll need create a VO that this query - and then add a viewlink to the full list.
    For example by using the employees table in the HR schema, which would be something like a VO with 'where manager_id is null' for the first level, as well as a link from there to the VO used to get other levels.

  • SQL queries for the date and year

    Hi friends,

    I have a named view - item_sales with 4 columns

    Item code

    Name of the element

    Transaction_YYYYMM (Date stored in a format YYYYMM)

    QTY_RECEIVED

    QTY_SOLD

    Sample data is

    ITEM_CODE POINT NAME TRANSACTION_YYYMM QTY_RECD QTY_SOLD

    TSHIRT 201307 3000 2000 AX

    TSHIRT AX 500 2000 201308

    TSHIRT 201309 1000 3000 AX

    CX 201307 3000 2000 XLSHIRT

    XLSHIRT CX 201308 3000 2500

    CX 201309 3000 2500 XLSHIRT

    END OF EACH MONTH I'LL RUN THIS QUERY TO FIND OUT THE DETAILS BELOW

    1. TO FIND NOM_ELEMENT WISE - QTY_RECEIVED AND QTY_SOLD (FOR THE CURRENT MONTH - EXAMPLE SEP)

    2. TO FIND NOM_ELEMENT WISE - QTY_RECEIVED AND QTY_SOLD (EXAMPLE EXERCISE OF JAN TO SEP)

    OUTPUT FOR SEPTEMBER MONTH LOOK LIKE THIS

    SEVEN MONTHS JAN TO SEP

    ITEM_CODE NOM_ELEMENT QTY_RECEIVED QTY_RECEIVED QTY_SOLD QTY_SOLD

    TSHIRT 1000, 3000, 6000, 5500 AX

    CX 3000 2000 9000 7000 XLSHIRT

    Pls advise me how to write queries for this

    RDK

    Hello

    This is called a Pivot, and here's a way to do it:

    WITH got_display_yyyymm AS

    (

    SELECT TO_CHAR (ADD_MONTHS (SYSDATE-1)

    , "YYYYMM.

    ) AS YYYYMM

    OF the double

    )

    SELECT i.item_code

    i.item_name

    SUM (CASE

    WHEN i.transaction_yyyymm = d.yyyymm

    THEN i.qty_received

    END

    ) AS month_received

    SUM (CASE

    WHEN i.transaction_yyyymm = d.yyyymm

    THEN i.qty_sold

    END

    ) AS month_sold

    SUM (CASE

    WHEN SUBSTR (i.transaction_yyyymm, 1, 4)

    = SUBSTR (d.yyyymm, 1, 4)

    THEN i.qty_received

    END

    ) AS year_received

    SUM (CASE

    WHEN SUBSTR (i.transaction_yyyymm, 1, 4)

    = SUBSTR (d.yyyymm, 1, 4)

    THEN i.qty_sold

    END

    ) AS year_sold

    Item_sales I have

    CROSS JOIN got_display_yyyymm d

    I.item_code GROUP, i.item_name

    ORDER BY i.item_code, i.item_name

    ;

    If you would care to post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data, then I could test it.

    The subquery got_display_yyyymm digit which is the previous month; It is not to change anything from month to month.  If you run the query in October 2013, then YYYYMM Gets the value '201309'.  If you run it in January 2014, then YYYYMM will be '201312'.

    As posted, it will work in Oracle 9.1 or higher.  The SELECT... PIVOT function that was introduced in Oracle 11.1 would not help in this problem, so you do not miss anything using Oracle 10 in this case.

  • Count queries and hierarchical

    Hi Oracle SQL gurus,

    Need your help in getting the counts of children for each parent - relationship to child using a hierarchical query.

    BANNER
    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    AMT for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL VERSION 10.2.0.1.0 - PRODUCTION


    Set of data to the top:

    SELECT 1 AS PROJECT,-1 AS PARENT_ID, CHILD_ID OF DOUBLE 1
    UNION
    SELECT 1, 1, 2 DOUBLE
    UNION
    SELECT 1, 2, 3, THE DOUBLE
    UNION
    SELECT 1, 3, 4 OF THE DOUBLE
    UNION
    SELECT 2, -1, 5 DOUBLE
    UNION
    SELECT 3, -1, DOUBLE 6
    UNION
    SELECT THE 3, 6, 7 DOUBLE

    Expected results:

    SELECT 1 AS project, -1 AS PARENT_ID, CHILD_ID AS, 4 as EXPECTED_ROW_COUNT FROM DUAL 1
    UNION
    SELECT 1, 1, 2, 3 DOUBLE
    UNION
    SELECT 1, 2, 3, 2 OF THE DOUBLE
    UNION
    SELECT 1, 3, 4, 1 DOUBLE
    UNION
    SELECT 2, -1, 5, 1 DOUBLE
    UNION
    SELECT 6-1, 2, 3 DOUBLE
    UNION
    SELECT 3, 6, 7, 1 FROM DUAL;


    Help, please.

    Thank you in advance.

    Hello

    Here's one way:

    SELECT       project_id, parent_id, child_id
    ,        COUNT (*)     AS expected_row_count
    FROM       table_x
    CONNECT BY     child_id     = PRIOR parent_id
    GROUP BY  project_id, parent_id, child_id
    ;
    
  • Convert data in hierarchal of hierarchical data for the creation of the tree

    Hi guys,.

    I tried to figure this out for about two days together now and I'm still stuck and I see no possible solution that does not involve a new creation of the table.
    I want to create a tree to navigate through projects and tasks, I use the demo "Task Manager" app, which I customized it a bit to fit my needs.

    Basically, I can't create the tree because the relationship between projects and tasks is not a hierarchical relationship, it's a relationship 1: n like this:

    __Projects__
    ID (PK)
    PROJECT NAME



    ___Tasks___
    ID (PK)
    Project (done FK reference Projects.ID)


    So what I have to do is to "force" this relationship 1: n with a hierarchical relationship by creating a query (view) that links the two tables into one and have 2 columns, I can use as ID and PARENT_ID for the creation of the tree.

    This is the data model:


    CREATE TABLE 'EBA_TASK_PROJECTS '.
    (NUMBER OF 'ID',
    'PROJECT_NAME' VARCHAR2 (255),
    "CREATED_ON" DATE NOT NULL ACTIVATE.
    'CREATED_BY' VARCHAR2 (255) NULL NOT ACTIVATE.
    DATE OF THE "UPDATED_ON"
    "UPDATED_BY' VARCHAR2 (255),
    'FLEX_01' VARCHAR2 (4000).
    'FLEX_02' VARCHAR2 (4000).
    'FLEX_03' VARCHAR2 (4000).
    'FLEX_04' VARCHAR2 (4000).
    'FLEX_05' VARCHAR2 (4000).
    NUMBER OF "PARENT_ID"
    VARCHAR2 (1) 'IS_ACTIVE ',.
    VARCHAR2 (4000) "DESCRIPTION."
    CONSTRAINT CHECK of 'EBA_TASK_PROJECTS_ACTIVE_CC' (in is_active ('Y', 'n')) ENABLE,.
    ENABLE 'EBA_TASK_PROJECTS_PK' CONSTRAINT PRIMARY KEY ('ID')
    ) ; ALTER TABLE 'EBA_TASK_PROJECTS' ADD 'EBA_TASK_PROJECTS_FK' OF CONSTRAINT FOREIGN KEY ('PARENT_ID')
    REFERENCES 'EBA_TASK_PROJECTS' ('ID') ON DELETE CASCADE ACTIVE;


    CREATE TABLE 'EBA_TASK_TASKS '.
    (SELECT 'ID' NUMBER NOT NULL,)
    ACTIVATE THE "PROJECT" NUMBER NOT NULL,
    ACTIVATE THE "TASK_PRIORITY" VARCHAR2 (400) NOT NULL,
    ACTIVATE THE "TASK_DIFFICULTY" VARCHAR2 (400) NOT NULL,
    ACTIVATE THE "TASKNAME" VARCHAR2 (4000) NOT NULL,
    VARCHAR2 (4000) "TASK_DETAILS."
    "CREATED_ON" DATE NOT NULL ACTIVATE.
    DATE 'DONE ',.
    ACTIVATE THE 'CREATED_BY' VARCHAR2 (400) NOT NULL,
    'STATUS' VARCHAR2 (4000).
    DATE OF THE "UPDATED_ON"
    "ON THE ROAD" DATE.
    NUMBER OF "TASK_PREDEFINED_ID."
    "UPDATED_BY' VARCHAR2 (255),
    ACTIVATE THE "USER_NAME" VARCHAR2 (255) NOT NULL,
    'FLEX_01' VARCHAR2 (4000).
    'FLEX_02' VARCHAR2 (4000).
    'FLEX_03' VARCHAR2 (4000).
    'FLEX_04' VARCHAR2 (4000).
    'FLEX_05' VARCHAR2 (4000).
    NUMBER OF "PERCENTAGE."
    ENABLE 'EBA_TASK_TASKS_PK' CONSTRAINT PRIMARY KEY ('ID')
    ) ; ALTER TABLE 'EBA_TASK_TASKS' ADD 'EBA_TASK_TASKS_PROJECTS_FK' OF CONSTRAINT FOREIGN KEY ('PROJECT')
    REFERENCES 'EBA_TASK_PROJECTS' ('ID') ON DELETE CASCADE ACTIVE;

    I use APEX4.0

    It's good enough that this guy, hope you can help me with this. I'm really stuck on this and I'm about to give up.

    Hello

    So what I have to do is to "force" this relationship 1: n with a hierarchical relationship by creating a query (view) that links the two tables into one and have 2 columns, I can use as ID and PARENT_ID for the creation of the tree.

    I'd say you need a UNION rather than a JOIN.
    Something like:

    WITH project_task_view AS (
     SELECT 'P'||to_char(id) as id
          , null as parent_id
          , project_name as node_name
     FROM eba_task_projects
     UNION ALL
     SELECT 'T'||to_char(id)
          , 'P'||to_char(project_id)
          , task_name
     FROM eba_task_tasks
    )
    SELECT id, parent_id, node_name, level
    FROM project_task_view
    START WITH parent_id IS NULL
    CONNECT BY PRIOR id = parent_id
    ;
    
  • Query of queries on 2 data sources

    I'm doing a query of queries on 2 different data sources. I run a gaming site and have a 2 programs that are used for tracking. One is written in php, by someone else, following members point State. The other, I wrote it in CF, allows members to set priorities in Treasury. Both are independent on my server. What I'm trying to do is set up so that the program I wrote to FC shows the number of points, each Member has. I know how interrogate separate tables, but how do I combine them? In addition, how can I set up so that it only shows members that match. that is, I want to assure you that if John Smith has 100 points, the query will show John Smith 100 points on my table. Here is what the query looks like I did. As you can see, I'm confused about and WHERE statements. I played with him last night and could not make it work. Thank you.

    You can try the same correction/idea of what I posted in thread http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid=1&catid=7

    Copied/Pasted from this thread:

    You can read through the first query and add content to a query to temp attributing some kind of field and then read through the second query and add same temp with a kind of field to the query. Then do a query of this temp query.

  • Assembler and hierarchical data Structure

    I am migrating an existing Flash Communication Server application to Flex Data Services. Everything is fine - I'm not using any framework, but simply running a singleton with scope, which manages a hierarchical structure complex. I want to be able to map Flex components client on specific portions of the server data tree - so, for example, if Customer.Employees.EmployeeList is updated, only the client component listens to the EmployeeList receives a synchronization. These client components would actually request a new copy of the EmployeeList. Other components with connections to other parts of the tree of the server data would have received no information.

    Can anyone give me any help on the best approach to this?

    Fixed, sort of. I did what I should do, except "Compile locally" did not work.

  • Need to use values from the first query in other queris to the data model

    Hello
    Here is my requirement-

    I use the data model to run multiple queries. The first query, I get 10 records. Now, I want to use these 10 records in the second query to get my final result. I am not able to use the sub query as the two motions are quite long and complex.

    Select distinct Bishop of emp

    Select empno, emp where Bishop in (: Bishop)

    I can't use: Bishop because it will give only the last value stored at Archbishop. Is it possible to be able to use all the values from the first query in the second query using the data model?

    Hello

    Are you sure that you have your "dataStructure" configured correctly? Try this simple example:

                                                                          
    

    Hope this helps

    Andy

  • Hierarchical data in the component of the tree should not be visible

    JDeveloper version - 11.1.1.7.0

    Default in the ADF, the performance of a page with a tree component, existing hierarchies are displayed as trees.


    For my requirement the TRIE hierarchies will not be displayed and component of the tree must be empty when the page runs.

    Why not just use the executeEmptyRowSet(), as described here:

    http://www.jobinesh.com/2010/05/displaying-empty-table.html

Maybe you are looking for