FIND ALL CHILD DEPARTMENTS

Dear All,
i have a table
create table dept(dept_id number primary key,
dept_name varchar2(100),
reference_dept number references dept(dept_id);
THERE is a main Department with dept_id=1
there are child of the 1 which are 2,3,4
if i choose the dept_id =4 then i want to select all the dept_id upto the parent dept_id i.e up to 1
and
if i choose the dept_id=1 then i want to select all the dept_id down the last chile dept_id i.e up to 4
how to do this?
thanks & Regards

For "journey" down by the tree you can use
select * from dept
start with dept_id = 1
connect by prior dept_id = reference_deptand for "journey" from bottom to the top of the three you can use
select * from dept
start with dept_id = 4
connect by dept_id = prior reference_dept

Similar Messages

  • Finding all child tables

    How can i find all the the child tables of a table? Is there an SQL query in Oracle by which i could get this info?

    Hi,
    select table_name, constraint_type
      from user_constraints
    where R_CONSTRAINT_NAME=  (select constraint_name
                                                         from user_constraints
                                                     where table_name = 'PARENT' and constraint_type = 'P')
       and constraint_type = 'R';Regards

  • Query ---  to find all child tables for a master table

    Suppose i have a table master .
    I want to know all tables which are child tables for this master table .
    In other words i want to know all those table names which have foreign key constraint for the master table .
    regards
    shubha

    You may want to join on the owner in case you have multiple schemas with same table names and same primary key names
    SELECT c.table_nameFROM all_constraints c, all_constraints p
    WHERE c.constraint_type = 'R'
    AND c.r_constraint_name = p.constraint_name
    AND p.constraint_type = 'P'
    AND c.owner = p.owner
    AND p.table_name = '&YOUR_MASTER_TABLE'

  • How to find all child tables

    Hi,
    I have a set of tables that are in multi level hierarchy.
    Here is the example.
    Table1 (id is primary key)
    Table2 (id,loc is primary key. and id is refering to table1.id) Table3(id,name is primary key and id is refering to table1)
    Table 4(emp_id,group,name,loc_grp is PK. emp_id and loc_grp is refering to table2) Table5(std_id,name,dpt,sal is pk and std_id,name is refering to table3)
    Now, I want to get all tables and their columns that are refering to Table1.id. In this example, it should return table2, table3,table4 and table5 along with their columns.
    some thing like this.
    Table_name Column_name
    Table2 id
    Table3 id
    Table4 emp_id
    Table5 std_id
    Please suggest how to get this.

    HI ,please try this one .
    SELECT a.table_name, c.column_name, b.table_name AS child_table,
           d.column_name, b.r_constraint_name
      FROM user_constraints a,
           user_constraints b,
           user_ind_columns c,
           user_cons_columns d
    WHERE a.constraint_type = 'P'
       AND a.constraint_name = b.r_constraint_name
       AND b.constraint_type = 'R'
       AND a.table_name = c.table_name
       AND a.constraint_name = c.index_name
       AND b.constraint_name = d.constraint_name
       AND a.table_name = '<TABLE_NAME>' ;thanks,
    P Prakash

  • Find all child tables - validate sql

    I have a table (tabA), In tabA i have a column (id) which is part of primary key
    Question: I need to know all the tables which have foreign keys refererring to tabA.id
    I used the following sql, please let me know if this is correct:
    select table_name
      from dba_constraints
    where (r_constraint_name) in ( select constraint_name
                                      from dba_constraints
                                     where table_name = 'tabA'
                                       and constraint_type in ( 'P', 'U' ) );

    On 11.2 you could try recursive subquery factoring:
    select *
    from ( with the_constraints( table_name
                               , constraint_name
                               , r_constraint_name
                               , lvl
           as ( select a.table_name
                ,      a.constraint_name
                ,      a.r_constraint_name
                ,      1 lvl
                from   all_constraints a
                where  a.table_name  = 'tabA'
                and    a.constraint_type = 'P'
                union all
                select c.table_name
                ,      nvl(( select constraint_name
                             from   all_constraints
                             where  table_name = c.table_name
                             and    constraint_type = 'P'
                          , c.constraint_name
                ,      c.r_constraint_name
                ,      lvl+1
                from   the_constraints p,
                       all_constraints c
                where  p.constraint_name = c.r_constraint_name
                and    c.constraint_type = 'R'
           search depth first by table_name set seq
           cycle table_name set is_cycle to 1 default 0
           select rownum rn
           ,      lpad('>', (lvl-1)*2, '-')||table_name relation
           ,      c.*
           from   the_constraints c
    order by rn desc;

  • Recursively iterating over all child controls

    Hi All,
    I'm trying to recursively iterate over all child controls in my Flex 4 application, and I've been doing something like this to get the immediate children of a particular container:
    public static function getElements(parent:Object):Vector.<IVisualElement>{
         var result:Vector.<IVisualElement> = new Vector.<IVisualElement>();
         for(var i:int = 0; i < parent.numElements; i++){
              result.push(parent.getElementAt(i));
         return result;
    I can then call that function recursively.  It works--kinda.  The way it doesn't work is that if I call this object on the application object itself, it will only give me back elements that are visible in the current state.  As I move from one state to another, different elements are returned by my getElements method.
    So, is there are way I can find all child elements, whether or not they are visible in the current state?
      -Josh

    Hi Josh,
    So, I've come up with some quick code for you. However, I must add my disclaimers first:
    The code is incomplete in that it excludes children of children that don't use states, but includes children of children that are associated with states of the parent. I'm also definitely not an expert in how our states system works.
    I'm not sure what your use case for all of this is, but my best guess is that it would be better to find a different way to solve your problem than to go the route of introspecting states. It's a long and dirty road =).
    Other than that, I've attached the code for you. The meat of this is:
         *  Finds all elements in all states that use the states of the specified parent.
        public static function getAllElements(parent:UIComponent):Vector.<IVisualElement>
            var container:IVisualElementContainer = parent as IVisualElementContainer;
            if (!container)
                return new Vector.<IVisualElement>();
            var result:Vector.<IVisualElement> = getCurrentElements(container);
            var states:Array = parent.states;
            for each (var state:State in parent.states)
                for each (var addItems:AddItems in state.overrides)
                    var elt:IVisualElement = addItems.items as IVisualElement;
                    if (elt && !containsElement(result, elt))
                        result.push(elt);
            return result;
    This method takes the parent container (in my case, the application) and returns a vector of children elements that associate themselves with the states of this parent container. First, it grabs all the elements already created from the parent container. Next, it iterates over each state and then each AddItems of each state. The AddItems object contains the information and pointers to the specific element that will be "added" when the current state changes to that state. By calling addItems.items, we force the creation of the specific element which is returned to us. Now, we can use a simple containsElement() method to check for duplicates and build a list of elements that would be added to each of the states.
    Again, the code is finding all of the children of the provided parent in all of its parent's states; however, it also finds children of children that may be using the parent's states as well. But if the children of children are not using the parent's states then it will not be found (easily fixable if you recurse). In addition, knowing which elements belong to which container just from introspecting the State object is pretty complicated and involves understanding how addItems.apply() works.
    Anyway, I hope this helps you. I would be interested in hearing your use case since this code is pretty complicated. I'd like to see if I could help by finding a different approach for your problem.
    -Kevin

  • Finding the complete hierarchy of all child records for a given root

    Hi,
    We need to find the hierarchy starting from a given root by exploding the hierarchy of each child present in the hierarchy.
    Consider a data as given below.
    Seq_no denotes a primary key.
    Child_id denotes the child node in the hierarchy
    Parent_id indicates the immediate parent of the child record
    Root_id denotes the starting point of the hierarchy.
    Within a given hierarchy the root_id will remain the same and parent_id will keep on changing as required.
    Seq_No Child_id     Parent_id     Root_id
    101          1          NULL     1
    102          2          1          1
    103          3          2          1
    104          4          1          1
    105          5          3          1
    106 4 NULL 4
    107 7 4 4
    108 8 4 4
    109 9 7 4
    110 3 NULL 3
    111 4 3 3
    112 5 3 3
    The requirement is to pull the hierarchy starting from a given root traversing down the path by exploding the hierarchy of each and every child present in that hierarchy. It is explained using below example.
    For root_id value as 4, the expected o/p is
    child_id path
    7 /7
    9 /7/9
    8 /8
    For root_id value as 3, the expected o/p is
    child_id path
    4 /4
    7 /4/7 ---> Hierarchy with root_id 4 gets exploded
    8 /4/8
    9 /4/7/9
    5 /5
    For root_id value as 1, the expected o/p is
    child_id path
    2 /2
    3 /2/3 ---> Hierarchy with root_id 3 gets exploded
    4 /2/3/4 ---> Hierarchy with root_id 4 gets exploded
    7 /2/3/4/7
    9 /2/3/4/7/9
    8 /2/3/4/8
    5 /2/3/5
    4 /4
    7 /4/7
    8 /4/8
    9 /4/7/9
    5 /5
    5 /2/3/5
    Also, additionally, if there exist any cyclic child records in the hierarchy, the exploding should stop there itself.
    CREATE TABLE xyz
    SEQ_NO NUMBER,
    ITEM_ID NUMBER,
    PARENT_ITEM_ID NUMBER,
    ROOT_ITEM_ID NUMBER
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (1, 1, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (2, 2, 1, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (3, 3, 1, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (4, 4, 2, 1);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (8, 3, 3);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (9, 10, 3, 3);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (10, 11, 10, 3);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (12, 10, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (13, 12, 10, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (14, 11, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (15, 13, 11, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (16, 14, 11, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (21, 23, 13, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (104, 16, 91, 14);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (19, 16, 12, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (20, 17, 16, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (101, 110, 110);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (102, 111, 110, 110);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (103, 17, 110, 110);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (29, 31, 17, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (30, 32, 17, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (31, 33, 16, 10);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (35, 49, 23, 11);
    Insert into xyz
    (SEQ_NO, ITEM_ID, ROOT_ITEM_ID)
    Values
    (41, 14, 14);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (42, 91, 14, 14);
    Insert into xyz
    (SEQ_NO, ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID)
    Values
    (43, 92, 91, 14);
    COMMIT;
    Pl advise.
    Thanks,
    - Ajit
    Edited by: 952105 on Aug 10, 2012 10:44 AM

    My application tracks the product master that stores a product configuration along with its all child/sub-child records. There exists many such configurations for various parts.
    There can exist only one configuration for a given product at any point in time. But, at the same time, this product can be a part of other product configurations too (i.e. it can exist as a child in other hierarchies).
    Now, the business requirement is to pull the hierachy starting from a given product (as a root). This should also pull the hierarchy of each child/subchild existing under its hieararchy, if there exist a separate configuration for those child/subchild products.
    SET DEFINE OFF;
    CREATE TABLE XYZ
    ITEM_ID NUMBER,
    PARENT_ITEM_ID NUMBER,
    ROOT_ITEM_ID NUMBER,
    QUANTITY NUMBER,
    LINE_ID VARCHAR2(10 BYTE)
    Here, root_item_id denotes the product for which the configuration has been defined. All its child/sub-child records gets stored under this root_item_id itself. The parent_item_id column will get stored appropriately based on the immediate parent of the product under that hierarchy.
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (2, 1, 1, 5, '1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (3, 1, 1, 5, '1.2');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (1, 1, 1, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (4, 2, 1, 6, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (10, 3, 3, 4, '1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (3, 3, 4, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (11, 10, 3, 15, '1.1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (10, 10, 7, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (12, 10, 10, 9, '1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (16, 12, 10, 99, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (17, 16, 10, 77, '1.1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (31, 17, 10, 2, '1.1.1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (33, 16, 10, 5, '1.1.1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (32, 17, 10, 3, '1.1.1.1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (14, 11, 11, 10, '1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (13, 11, 11, 9, '1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (11, 11, 8, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (23, 13, 11, 77, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (49, 23, 11, 5, '1.1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (16, 91, 14, 56, '1.1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (92, 91, 14, 10, '1.1.1');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (91, 14, 14, 8, '1.1');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (14, 14, 6, '1.0');
    Insert into XYZ
    (ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (110, 110, 1, '1.0');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (17, 110, 110, 1, '1.2');
    Insert into XYZ
    (ITEM_ID, PARENT_ITEM_ID, ROOT_ITEM_ID, QUANTITY, LINE_ID)
    Values
    (111, 110, 110, 1, '1.1');
    COMMIT;
    The expected result for product with root_item_id as 14
    item_id hierarchy_path
    11 /11
    13 /11/13
    23 /11/13/23
    49 /11/13/23/49
    14 /11/14 -- it should explode the hierarchy of product with id 14
    91 /11/14/91 as there exists a configuration for this product as a root
    16 /11/14/91/16
    92 /11/14/91/92
    In above example, it should explode the hierarachy of other products too (item_id 13,23 etc) if there exists a product configuration (starting with root_item_id as 13 or 23 etc.) for them in the table.
    Thanks,
    - Ajit

  • User being removed from Domain Admins...how to find all servers his account is being used.

    We have a user that is being removed from IT (more like being forcefully demoted) and our owner still finds him valuable in other departments. My challenge is to find all servers that he may be using his account locally on (as a service or added to a local
    admin group). It hasn't happened yet, but we need to be prepared to say we know all the servers his account is on when the owner demotes him.
    I'm hoping someone has an approach to this that doesn't include going through tons of Event Viewer Security logs. We do have System Center Configuration Manager and Operations Manager 2012 w/ SP1, but the guy that is responsible for those is the guy we are removing
    and none of us are aware on how to use the possible tools that those have. If you feel that those would do the trick then please point me to a "how to" and I'll try to learn on the fly. Otherwise I'll take any other suggestions.
    ~Rick

    Hi Rick,
    Based on my research, you can filter events logs based on user name and event ID:
    Advanced XML filtering in the Windows Event Viewer
    http://blogs.technet.com/b/askds/archive/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer.aspx
    Best Regards,
    Amy

  • Function module to find the child of WBS elements

    Hi,
    i need to find the KSTAR (Cost Element) for the corresponding WBS element . If the particular WBS element does not contain the COST Element, then to find all the children WBS element .
    I need to find all the child WBS elements and its level for the parent WBS element. I am using the table COSB and PRPS table . kindly solve to find a FUNCTIONAL MODULE which uniquely  the child WBS element. Kindly help to solve.

    Hit the PRPS table where STUFE(Level in Project Hierarchy) > Current level and project Id = Current project ID.
    Hope it helps.
    Reward if it is useful.
    Thanks,
    Srinivas

  • FindChildIndex cannot find the child with the given itemName

    Hi,
    I am getting error " findChildIndex cannot find the child with the given itemName" when runs the page from jdeveloper.
    I didnt use findChildIndex in my CO or AM.
    Please help me to resolve it.
    Thanks
    Amit Jaitly

    Amit
    Check old threads
    Re: how to call concurrent programs from oaf page
    http://forums.oracle.com/forums/search.jspa?threadID=&q=findChildIndex+cannot+find+the+child+with+the+given+itemName&objID=f210&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks
    AJ

  • Find parent/child relationships At More Than 2 Levels

    Hello,
    Does anyone have a solution to find parent/child relationship for data more than 2 levels deep?
    I have a solution when there's a simple parent-child relationship but not when there's a grandparent-parent-child relationship or deeper.
    Ex. I have a table company_parent_child that stores the relationship betwen a company and it's direct parent.
    create table TEMP_COMPANY_PARENT_CHILD
    PARENT_ID NUMBER(10),
    COMPANY_ID NUMBER(10)
    insert into TEMP_COMPANY_PARENT_CHILD values (1, 10);
    insert into TEMP_COMPANY_PARENT_CHILD values (1, 11);
    insert into TEMP_COMPANY_PARENT_CHILD values (1, 12);
    insert into TEMP_COMPANY_PARENT_CHILD values (2, 13);
    insert into TEMP_COMPANY_PARENT_CHILD values (10, 100);
    insert into TEMP_COMPANY_PARENT_CHILD values (10, 101);
    insert into TEMP_COMPANY_PARENT_CHILD values (10, 102);
    insert into TEMP_COMPANY_PARENT_CHILD values (11, 103);
    1->
    ___10->
    ______100,101,102,
    ___11->103
    Companies 100, 101 and 102 are under parent 10 and grandparent 1.
    I need to create such a view or another temp table so that when I pass the parent ID, I will pull all the children on all levels. In addition, and this is the tricky part, when I join this new temp table or view to another data table without any parameters, the data should not be duplicate, ie. each company ID should appear only once.
    create table TEMP_JOIN
    company_id number(10),
    order_id varchar2(10)
    insert into TEMP_JOIN values (100, 'a');
    insert into TEMP_JOIN values (101, 'b');
    insert into TEMP_JOIN values (102, 'c');
    insert into TEMP_JOIN values (103, 'd');
    insert into TEMP_JOIN values (10, 'e');
    insert into TEMP_JOIN values (11, 'f');
    insert into TEMP_JOIN values (12, 'e');
    insert into TEMP_JOIN values (13, 'f');
    Thanks.

    start by learning CONNECT BY/START WITH. once you've
    written a query to read the grandparent-parent-child
    relationship, then come back with more questionsYes. we did look heavily into connect by/start with, in fact along with "connect_by_iscycle","connect_by_isleaf","connect_by_root" as well.
    Our dilemma is that when a joint is made between those two tables mentioned above TEMP_COMPANY_PARENT_CHILD and TEMP_JOIN, we are not able to create a view that would contain distinct company_ids, each mapped to a unique order id.
    The problem is we cannot have this type of joint when there are "n" level relationship between companies (or company_id). Basically, I think we should have our unique order id mapped to a unique key. This unique key should be a specialized key that we can know at anytime the entire path of the ancestry which we can know by sys_connect_by_path(company_id,'/') path.
    How do we know which path to take. The best bet is to "connect_by_isleaf" and just have the distinct "deep" path which form the specialized unique key. If you need help on this let me know. (A hint, sort by LEVEL and then do a rank after partitioning by company id and then filter the records by rank = 1, try this one!!!)
    So, we will eventually have a joint (say Table X) like
    PATH ORDER_ID
    /1/10/100 a
    /1/10/101 b
    /1/10/102 c
    /1/10 e
    /1
    /1/11/103 d
    /1/11 f
    I think this is the best view we can have to maintain a joint with no repetition along PATH as well as ORDER_ID. If you have any other thoughts, let me know.
    Then you query by path using INSTR to pull records by company_id.
    for example, if you want to get all the children for company_id "10" you would just say
    select * from X where INSTR(PATH,10,1,1) <> 0
    or if you want to get all the children for company_id "11" you would just say
    select * from X where INSTR(PATH,11,1,1) <> 0
    What do you think? Has anyone used the path information for traversing the tree? Or is there any article that tells us how to make effective use of sys_connect_by_path(company_id,'/') path.
    Thank you. Hope it made sense!

  • Find All Occurrences always fails within loop

    Dear forumers,
    There's this strange problem that requires a fix.
    Finding all occurences of '#' works fine here:-
    REPORT  zz_test.
    DATA: lv_text TYPE string,
          ls_result TYPE match_result,
          et_release type table of yytc_release,
          lt_result  TYPE match_result_tab.
    lv_text = '"RFC-1234#Create ""Payroll"" under NL directory"'.
      FIND ALL OCCURRENCES OF REGEX '#'
                IN lv_text
                RESULTS lt_result IGNORING CASE IN CHARACTER MODE.
      IF sy-subrc = 0.   " SY-SUBRC is always 0
        READ TABLE lt_result INTO ls_result INDEX 1.
        WRITE :'Offset: ' .
        WRITE: ls_result-offset .
        WRITE: lv_text+00(ls_result-offset).
      ENDIF.
    But it always fails here, within a loop at an internal table:-
    SELECT * .... INTO TABLE it_jira ...
    LOOP AT it_jira ASSIGNING <jira>.
      <release>-summary = <jira>-summary.
      IF <release>-type CS 'Subtask'.
        " <release>-summary is of data type CHAR255
        PERFORM get_subtask USING <release>-summary.  
      ENDIF.
    ENDLOOP.
    FORM get_subtask  USING    pv_summary TYPE yytc_release-summary.
      DATA:
        lv_string  TYPE char255,
        lv_final   TYPE char255,
        lv_summary TYPE string,
        lv_strlen  TYPE i,
        lt_result  TYPE match_result_tab.
      lv_string = pv_summary.     " LV_STRING = '"RFC-1234#Create ""Payroll"" under NL directory"''
      CONDENSE lv_string.
      lv_strlen = STRLEN( lv_string ).
      lv_strlen = lv_strlen - 1.
      IF lv_string+0(1) = '"' AND lv_string+lv_strlen(1) = '"'.
        lv_strlen = lv_strlen - 1.
        WRITE lv_string+1(lv_strlen) TO lv_final+1(254).
      ENDIF.
      lv_summary = lv_final.
    "  FIND ALL OCCURRENCES OF '#'
    "      IN lv_summary
    "    RESULTS lt_result IGNORING CASE.   * SY-SUBRC is always 4 here too
      FIND ALL OCCURRENCES OF REGEX '#'
          IN lv_summary
        RESULTS lt_result IGNORING CASE IN CHARACTER MODE.
      IF sy-subrc = 0.    " SY-SUBRC is always 4 here - why?!  :(
      ENDIF.
      CLEAR: lv_string,
             lt_result.
    ENDFORM.                    " GET_SUBTASK
    Only when the string LV_SUMMARY is edited from within the debugger (add space to the string prefix, etc), the SY-SUBRC will be 0 and there'll be data found in LT_RESULT.
    How can I resolve this issue? Please do help. Thanks.

    I think the subtle difference is that in your first example the character is actually '#' whereas in the second example it is actually another (unprintable)value such-as line-feed and only APPEARS to be '#'.
    You must find out what the value in question is(will it always be the same value?) and then replace that instead of '#'.

  • How do I find all the purchased items on my iPhone? When I try to update the iPhone iOS while connected to my MacBook it says there are purchased items on the phone that have not been transferred to my iTunes library and that I should transfer them.

    How do I find all the purchased items on my iPhone? When I try to update the iPhone iOS while connected to my MacBook it says there are purchased items on the phone that have not been transferred to my iTunes library and that I should transfer them before updating.

    Thanks. This seems to have worked easily.

  • When looking at my "About This Mac" it says that I have 60gb of space left on my hard drive, but when I go into finder to find all of these files there is not 300gb worth in anything I search, even searching, "All files on the Mac". Help!?

    When looking at my "About This Mac" it says that I have 60gb of space left on my hard drive, but when I go into finder to find all of these files there is not 300gb worth in anything I search, even searching, "All files on the Mac". Help!?
    It says I have over 150 gigs of video on my hard drive. But I have gone through and deleted almost all of what shows up, still it says there is roughly the same amount on the hard drive. Where are these files? I want to delete them so I can have my hard drive clear.
    Thanks for your help guys!

    Quote from the article.
    Time Machine in OS X Lion includes a new feature called "local snapshots" that keeps copies of files you create, modify or delete on your internal disk. Local snapshots compliment regular Time Machine backups (that are stored on your external disk or Time Capsule) giving you a "safety net" for times when you might be away from your external backup disk or Time Capsule and accidentally delete a file.
    So what makes a notebook any different then a desktop, other then with a desktop you might have your tm backup drive connected all the time.
    The object here is to not indiscriminately delete files you need or want to keep. I personally have never deleted a file I wanted to keep.
    In essence a backup is for catastrophic failure of your system. So it can be restored once that failure has been fixed. Not because you go in willy nilly and start deleting files.

  • My Top Rated songs, when I synch my iP4S - comes up with an error message saying it can't find all the songs. When I check, library has songs listed but with a "!" bubble next to them. When I click on them they play. What am I doing wrong?

    When synching, itcomes up with an error message saying it can't find all the songs. When I check, library has songs listed but with a "!" bubble next to them. When I click on them they play. What am I doing wrong? This happens every time so I click them and it sorts them (boring with 200 odd). How can I prevent this?

    Once you successfully add you iTunes library to iTunes Match, you go to Settings>iTunes & App Store on your iOS device and turn on iTunes Match.  Your iTunes Match library will then appear on your iOS device.

Maybe you are looking for

  • HT201303 My security questions aren't working is there a way to reset them?

    My ID keeps asking for security questions I dont remember them is there a way I can get them or reset them?

  • Data limitation for inserts with JDBC?

    I'm having problems with inserting data using JDBC that came with Oracle 8.1.5. I'm inserting text into a long field. It works fine until i approach 99K+. The error i'm receiving is "unimplemented or unreasonable conversion requested". If i remove so

  • Deleting Email Adress in Scan - HP 5520

    Hi,I have entered a wrong email address in the "Scan to Email" dialogue. Now I want to delete this email, but I am requested to enter the PIN  - which of course I do not have. But I cannot remove an email address without the PIN. What should I do? Re

  • Buzzing from speakers when movement on screen

    Hi there, I've a bit of a bizarre issue, and I'm wondering if anyone has any suggestions... I recently acquired a set of Mackie MR5 reference monitors, and am running them through a Tapco LINK.usb audio interface. They work great, with the exception

  • Problems on X6 afther upgrading to v 30.0.003

    Hi, I have few problems since tha las update to v 30.0.003.240.08 I'm from Spain and my phone compay is movistar. One of the problems is that there is no way to make de GPS to go online on the net, I can only use it on offline mode, and the tool to c