Multi-Org Parent-Child LOV

Issue Description:
in Action BC (Table: S_EVT_ACT) we are trying to implement the following organization based parent child picklists/LOVs for Status->Status Reason
[Status] - Activity Status field (col: EVT_STAT_CD)
*Picklist: LOV Type = 'EVENT_STATUS', picklist BC: 'List Of Values Dynamic (REL)'
[LN Status Reason] - customised field/column (Col: X_STATUS_REASON)
*Picklist: LOV Type = 'LN_MISSED_ACTIVITY_REASON', picklist BC: 'PickList Hierarchical'
*Pick Map: [LN Status Reason] = [Value], [Status] = [Parent] (Constraint = Y)
in the Admin-Data LOVs:
Type = EVENT_STATUS, Display Value/LIC = "Not Achieved", Organization = "Org 1"
Type = LN_MISSED_ACTIVITY_REASON
Display Value/LIC = "Reason 1", Parent LIC = "Not Achieved", Organization = "Org 1"
Display Value/LIC = "Reason 2", Parent LIC = "Not Achieved", Organization = "Org 1"                                                                                          
On UI, create new record in Account - Activities, selecting Status = "Not Achieved".
Now when i try to select the Status Reason value, the drop down does not give me any value.
If I set the Organization to blank on "Reason 1", then the "Reason 1" value shows up in the Status Reason drop down under Account - Activities.
In SQL of the log file, for the Status Reason drop down, it always hard code a T1.BU_ID is null in the WHERE clause, this would explain why its blank in the dropdown
Also as a test, If i remove all the pick map constraints for the [LN Status Reason] field (ie the only record in the pick map is [LN Status Reason] = [Value]), then the drop down works correctly (ie displaying both the values with Organization = "Org 1"), and in the SQL of the log file, instead of BU_ID is null, it has BU_ID = ? with variable binding.
Is there a reason why it would hard code the BU_ID is null in the WHERE clause in the SQL, and how to overcome this to achieve my requirement.
Just a further update due to character limit of the original description,
The "Owner Organization Specifier" property on the table S_EVT_ACT is blank (not sure if its related to anything though)
The user i'm using belongs to "Org 1" for both the employee's Organization and its Position's Organization
Thanks

This is exactly what I'm looking for...I just can't make it work. I have 2 tables (database and schema). They are related via a database_id column. My code is below if you are willing to help.
HTML Header
<script>
function get_select_list_xml1(pThis,pSelect){
var l_Return = null;
var l_Select = html_GetElement(pSelect);
var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
'APPLICATION_PROCESS=CASCADING_SCHEMA',0);
get.add('P7_DATABASE',pThis.value);
gReturn = get.get('XML');
if(gReturn && l_Select){
var l_Count = gReturn.getElementsByTagName("option").length;
l_Select.length = 0;
for(var i=0;i<l_Count;i++){
var l_Opt_Xml = gReturn.getElementsByTagName("option");
appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'),
l_Opt_Xml.firstChild.nodeValue)
get = null;
function appendToSelect(pSelect, pValue, pContent) {
var l_Opt = document.createElement("option");
l_Opt.value = pValue;
if(document.all){
pSelect.options.add(l_Opt);
l_Opt.innerText = pContent;
}else{
l_Opt.appendChild(document.createTextNode(pContent));
pSelect.appendChild(l_Opt);
</script>
Application Process
BEGIN
OWA_UTIL.mime_header ('text/xml', FALSE);
HTP.p ('Cache-Control: no-cache');
HTP.p ('Pragma: no-cache');
OWA_UTIL.http_header_close;
HTP.prn ('<select>');
HTP.prn ('<option value="' || 0 || '">' || '- All Schemas -'
|| '</option>'
FOR c IN (SELECT schema, schema_id
FROM (SELECT schema, schema_id, database_id
FROM schema_lookup
WHERE database_id = :cascading_selectlist_item_1)
LOOP
HTP.prn ('<option value="' || c.schema_id || '">' || c.schema || '</option>');
END LOOP;
HTP.prn ('</select>');
END;
P7_DATABASE_ID Form Element Attribute
onchange="get_select_list_xml1(this,'P7_SCHEMA_ID');
P7_SCHEMA_ID LOV
select SCHEMA d, SCHEMA_ID v from SCHEMA_LOOKUP
where DATABASE_ID = :P7_DATABASE_ID
order by 1

Similar Messages

  • Multi level parent child relationship and datacontrol

    I have an existing application with multi-level parent child tables. For example three of the tables in the applications are related as Table 1 ( parent of Table 2) ---> Table 2 ( parent of Table 3 ) --> Table 3. When i create ADF Business components using these tables i see only the nesting between the parent and its immediate child tables. How can i create a nested data control for Table 3 to Table 2 to Table 1?. We have a usecase where we need to access data from the child table to parent to parent in the reverse order. Currently there is no direct relationship defined between Table 1 and Table 3.
    Any thoughts?
    thanks
    Seetharaman

    Hi,
    double click the Application Module to open the AM editor. Select the data Model category. On the right hand side you see what is selected for use in an application, on the left hand side is what you have available as View Object. To create T1-->T2-->T3, you
    - Select T1 and move it to the right
    - Select T2 under T1 on the left and move it to the right under T1
    - Select T3 under T2 on the left and move it under T2 in T1 on the right
    Frank

  • APEX 4.1 dynamic parent child LOV

    Is is possible to create a dynamic parent child LOV? I want to be able to use information populated by a user on a form to become a select list on a subsequent form where the second field (child) is dependent on what is selected on the first field (parent). The list needs to grow based on data entered on the initial form and maintain the relationship.

    You should post this in the APEX forum.
    Oracle Application Express (APEX)
    Please open a thread on the APEX forum, update this thread with the link to the new thread and the mark this thread ANSWERED.

  • Select List (Parent/Child) LOV

    I have the Easy Oracle HTML-DB book, they give an example of a
    Parent Child Select List using a query.
    Does anyone know how to apply the Parent/Child relationship with
    a List of Value generated from a table.
    Example
    Parent Child
    Car Pontiac
    Car Buick
    Car Cadillac
    Car Nissan
    Truck Tahoe
    Truck Silverado
    Truck F150
    Truck Titan
    The parent(s) in the above example are Car/Truck, the children are in the adjacent column.
    Objective: When the parent "Car" is chosen, only the "Pontiac/Buick/Cadillac/Nissan" will be available, once the child is selected,
    wish to submit to a empty table that can grow dynamically.
    OS: Windows: XP
    Oracle ver.: 10g
    Apex ver.: Release 2

    Hi,
    are you just having one table storing all the values?
    1) Create a "Select list with Submit"
    2) Lov query would be something like
    SELECT DISTINCT
           CAR_TYPE AS D
         , CAR_TYPE AS R
      FROM WHATEVER_TABLEThe distinct is only because you have mixed your parent and child values in one table instead of having two separate tables with a FK from the child to the parent.
    3) Create another "Select List"
    4) Lov query would be something like
    SELECT CAR AS D
         , CAR AS R
      FROM WHATEVER_TABLE
    WHERE CAR_TYPE = :P2_CAR_TYPE-> in the where clause you restricting the second lov with the value the user has selected in the first select list.
    The first "Select List with Submit" will trigger a full page refresh when you select a car type. If you want to avoid that you can use the AJAX based "Cascading Lov" feature of my ApexLib Framework (see http://apex.oracle.com/pls/otn/f?p=33231:4 ) or search on the forum for "cascading lov ajax" for other similar solutions.
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Parent-child LOV dependencies

    Hi
    i have a problem, i have to create 2 lov, a parent LOV and a child LOV....the Child LOV have to depend from the first LOV. The problem is that i can't execute submit after the first selection, because these lovs is in a Tabular form......first lov in the first column and second lov in the second column.
    How can i do?
    Thanks

    Hi,
    See this link: http://htmldb.oracle.com/pls/otn/f?p=31517:234:3947371667335265:::RP,::
    thanks
    Tauceef

  • Handling cascading LOV (having Multi-Select parent LOV)

    Hi,
    I am using cascading LOV.
    P1_PARENT - Parent LOV (which is multi-select)
    P1_CHILD - Child LOV
    since Parent LOV is multi-select, so it will have the following vallues... P1_PARENT = AA:BB:CC
    and the where clause in the cascading LOV should be like
           where col1 in (:P1_PARENT)
       - So how to convert item value for P1_PARENT from AA:BB:CC to 'AA','BB','CC'
    - Is there is any other way to handle cascading LOV (for Multi-Select parent LOV).
    select list for P1_CHILD
        select d, r
      from test
    where col1 = :P1_PARENT
    where col1 in (:P1_PARENT) Thanks,
    Deepak

    Hi Deepak,
    In the where clause for the child LOV, you can use instr function as:
    (instr(':'||:P1_PARENT||':',':'||col1||':',1) > 0 ) To access the individual elements in the multi-select :P1_PARENT, you can use:
    DECLARE
    l_selected HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    BEGIN
      l_selected := HTMLDB_UTIL.STRING_TO_TABLE(:P1_PARENT);
      FOR i IN 1..l_selected.count
      LOOP
            //  your code here...access individual elements using  l_selected(i)
      END LOOP;
    END;Thanks,
    Rohit

  • Sum within a self-contained parent-child table

    I have two tables - a "key" table containing a multi-layer parent-child relationship, and an "amount" table containing the keys for the leaf nodes in the key table as well as numeric values (e.g. amounts).
    I want a query that returns each row in the key table as well as the sum of the amount table's amounts for all of that key's leaf nodes (so the root node would have the sum of all of the amount values).
    Here's what I mean - I have two tables, KEY and AMOUNT
    KEY has two columns, key and parent_key; key and parent_key have a CONNECT BY relationship on parent_key = prior key (with parent_key null for the root):
    KEY     PARENT_KEY
    0       null
    1       0
    2       0
    3       0
    1A      1
    2A      2
    2B      2
    3A      3
    3B      3
    3C      3
    1A1     1A
    1A2     1A
    2A1     2A
    2A2     2A
    2B1     2B
    3A1     3A
    3A2     3A
    3C1     3C
    3C2     3CAMOUNT has two columns, key and amount; key points to KEY.key, and amount is a value for that particular key
    (note that all key values are leaf nodes in the KEY table)
    KEY     AMOUNT
    1A1     1
    1A2     2
    2A1     3
    2A2     4
    2B1     5
    3A1     6
    3A2     7
    3C1     8
    3C2     9 What I want is a result that looks like this, where each key's amount is the sum of its eventual leaf keys' amounts
    KEY     AMOUNT
    0       45
    1        3
    2       12
    3       30
    1A       3
    2A       7
    2B       5
    3A      13
    3B       0
    3C      17
    1A1      1
    1A2      2
    2A1      3
    2A2      4
    2B1      5
    3A1      6
    3A2      7
    3C1      8
    3C2      9For example, key 2A's value, 7, is the sum of the values of 2A1 and 2A2; key 3's value is the sum of 3A1, 3A2, 3C1, and 3C2.
    Is there a way of doing this with a single query?
    The idea I came up with is, do a select on KEY with a "CONNECT_BY_PATH key" column so each row includes a string containing the keys of all of its ancestors, and then do a join on AMOUNT with amount.key IN the CONNECT_BY_PATH column; however, with a larger amount of data, this takes quite a bit of time. Is there a faster / more obvious way of doing this?

    SQL> with key_tbl as (
      2                   select '0' key,null parent_key from dual union all
      3                   select '1','0' from dual union all
      4                   select '2','0' from dual union all
      5                   select '3','0' from dual union all
      6                   select '1A','1' from dual union all
      7                   select '2A','2' from dual union all
      8                   select '2B','2' from dual union all
      9                   select '3A','3' from dual union all
    10                   select '3B','3' from dual union all
    11                   select '3C','3' from dual union all
    12                   select '1A1','1A' from dual union all
    13                   select '1A2','1A' from dual union all
    14                   select '2A1','2A' from dual union all
    15                   select '2A2','2A' from dual union all
    16                   select '2B1','2B' from dual union all
    17                   select '3A1','3A' from dual union all
    18                   select '3A2','3A' from dual union all
    19                   select '3C1','3C' from dual union all
    20                   select '3C2','3C' from dual
    21                  ),
    22    amount_tbl as (
    23                   select '1A1' key,1 amount from dual union all
    24                   select '1A2',2 from dual union all
    25                   select '2A1',3 from dual union all
    26                   select '2A2',4 from dual union all
    27                   select '2B1',5 from dual union all
    28                   select '3A1',6 from dual union all
    29                   select '3A2',7 from dual union all
    30                   select '3C1',8 from dual union all
    31                   select '3C2',9 from dual
    32                  )
    33  select  key,
    34          nvl(sum(amount),0) amount
    35    from  (
    36           select  connect_by_root k.key key,
    37                   amount
    38             from  key_tbl k,
    39                   amount_tbl a
    40             where a.key(+) = k.key
    41             connect by k.parent_key = prior k.key
    42          )
    43    group by key
    44    order by key
    45  /
    KEY     AMOUNT
    0           45
    1            3
    1A           3
    1A1          1
    1A2          2
    2           12
    2A           7
    2A1          3
    2A2          4
    2B           5
    2B1          5
    KEY     AMOUNT
    3           30
    3A          13
    3A1          6
    3A2          7
    3B           0
    3C          17
    3C1          8
    3C2          9
    19 rows selected.
    SQL> SY.

  • How to make Sales Person LOV org specific in case of Multi Org Setup

    HI,
    We are working on 11.5.10.2
    We have a multi org setup and i am required to make the sales person LOV to populate only the org specific salespersons, at the sales order, quote, service contract levels.
    Is it achiveable and if yes.....please letme know the way.
    Reg,
    Ajay Agarwal.

    Hi
    Try to play around with the security profile in the HRMS and attach it to the responsibility level
    Regards
    Ramesh Kumar S

  • Restful: Child lov with parent prompt

    I have 2 dimensions, Parent and Child. The list of values of the Child dimension contains a prompt on the parent. With restful, I want to the the list of values for the child dimension. I've created a webi document with a prompted filter on the Child dimension. So I have 2 prompts one the webi document, one from the Child dimension and one from the list of values of the child dimension.
    A call GET http://{hostname}:6405/biprws/raylight/v1/documents/{documentID}/parameters/{parameterID} for the child prompt returns the expected xml:
    <lov hierarchical="false" refreshable="true">
    <id>UNIVERSELOV_DS0.DO4</id>
    <parameters>
    <id>0</id>
    </parameters>
    </lov>
    where 0 is the id of the parent dimension
    I then use the resful call PUT http://{hostname}:6405/biprws/raylight/v1/documents/{documentID}/parameters/{parameterID} to answer the parent and the child's lov.
    When the prompt on the parent in the list of values is not optional, everything is fine but when the prompt is optional, I get the error :
    Bad Request WSR 00102 - Illegal argument (Suspicious identifier(s): [0])
    In both case, I use the input xml (with true or false value for optional attribute of parameter):
    <parameters>
         <parameter optional="true|false">
              <id>0</id>
              <answer>
                   <values><value id="10" >Parent 10</value></values>
              </answer>
         </parameter>
         <parameter>
              <id>1</id>
              <answer>
                   <info><lov><query intervalId="0" intervalSize="10000" /></lov></info>
              </answer>
         </parameter>
    </parameters>
    If I use the refresh="true" attribute to the query tag, I don't get any value for the child lov only:
    <lov hierarchical="false" refreshable="true">
    <id>UNIVERSELOV_DS0.DO4</id>
    </lov>
    Any ideas?

    Eric,
    I hope it's not an issue but an invalid input XML.
    I just made some good progress. The restful documentation states that "The <info> element is not mandatory in the XML inputs, except in the case of cascading parameters and hierarchical parameters.", so I surround the values tag by a info tag and it almost works in both cases (mandatory and optional parent prompt). The XML input is
    <parameters>
       <parameter>
          <id>0</id>
          <answer>
             <info>
                <lov>
                   <query intervalSize="-1" />
                </lov>
             </info>
             <values>
                <value id="1">Parent 1</value>
                <value id="3">Parent 2</value>
             </values>
          </answer>
       </parameter>
       <parameter>
          <id>1</id>
          <answer>
             <info>
                <lov>
                   <query intervalSize="-1" />
                </lov>
             </info>
          </answer>
       </parameter>
    </parameters>
    But one problem solves, one problem raises. When a answer no parent value (<values></values>), I get in return of a PUT call, the same result as a GET call:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <parameters>
        <parameter dpId="DP0" type="prompt" optional="false">
            <id>0</id>
            <technicalName>pmParent(s)?</technicalName>
            <name>Parent(s)?</name>
            <answer type="Text" constrained="true">
                <info cardinality="Multiple">
                    <lov refreshable="true" partial="false" hierarchical="false">
                        <id>UNIVERSELOV_DS0.DO1</id>
                        <updated>2014-10-09T12:54:54.000+01:00</updated>
                        <values>
                            <value id="1">Parent 1</value>
                            <value id="2">Parent 2</value>
                            <value id="3">Parent 3</value>
                        </values>
                        <columns mappingId="0">
                            <column type="String" id="0">Parent </column>
                        </columns>
                    </lov>
                    <previous>
                        <value id="1">Parent 1</value>
                        <value id="3">Parent 2</value>
                    </previous>
                </info>
                <values>
                    <value id="1">Parent 1</value>
                    <value id="3">Parent 2</value>
                </values>
            </answer>
        </parameter>
        <parameter dpId="DP0" type="prompt" optional="true">
            <id>1</id>
            <technicalName>pmChild(ren)?</technicalName>
            <name>Child(ren)?</name>
            <answer type="Text" constrained="true">
                <info cardinality="Multiple">
                    <lov refreshable="true" hierarchical="false">
                        <id>UNIVERSELOV_DS0.DO3</id>
                        <parameters>
                            <id>0</id>
                        </parameters>
                    </lov>
                    <previous>
                        <value id="21">Child 21 - 2</value>
                    </previous>
                </info>
                <values>
                    <value id="21">Child 21 - 2</value>
                </values>
            </answer>
        </parameter>
    </parameters>
    Nevertheless, I get a workaround for this situation, instead of not answering the parameter, I have to answer all possible values. It's not a nice solution and I hope a better one exists.
    The results are the same with
    http://{hostname}:6405/biprws/raylight/v1/documents/{documentID}/parameters/{parameterID}/
    and with
    http://{hostname}:6405/biprws/raylight/v1/documents/{documentID}/parameters/
    except, of course that when using first url, the return xml contains only one parameter (the one in the url)
    Regards

  • Multi parent child in a AppModuleDataControl

    Hi
    I'm trying to create an application that require multiple (5+) level of parent/child relationship in a AppModuleDataControl...
    (using the following tutorial as an example: http://docs.oracle.com/cd/E37547_01/tutorials/tut_rich_app/tut_rich_app_2.html)
    Is it something that is possible?
    Thanks in advance

    User, please tell us your jdev version.
    Yes, this is possible. Where do you see a problem? If your data mode has this kind of relationship you can build it (or if the foreign keys are setup in the db you get it automatically). a sample up to lever 3: JDeveloper &amp;amp; ADF: Multiple Cascading Tables | JDev &amp;amp; ADF Goodies
    Timo

  • ESYU: R12 - Order Management를 위한 Multi Org Access Control(MOAC) setup 방법

    Purpose
    Oracle Order Management - Version: 12.0 to 12.0
    Information in this document applies to any platform.
    R12의 Order Management에 대핸 Multi Org Access Control(MOAC) setup 방법에 대해 알아본다.
    Solution
    일반적인 MOAC Setup:
    1. HRMS에서 Security Profile을 정의:
    a. HRMS Management responsibility 선택
    b. HRMS Manager> Security> Profile로 이동
    c. Security Profile이 정의되어 있는지 확인 (OM responsibility 혹은 Site level로)
    d. 만일 아직 setup 되어져 있지 않다면 Operating Units를 입력
    e. 저장
    Note: 만일 위 d step과 같이 새로운 security profile을 생성하였다면 concurrent program 'Security List Maintenance'를 꼭 실행해야 한다.
    그렇지 않으면 multiple operating units가 OM forms의 LOV에 나타나지 않을 것이다.
    이 program은 multi-org access를 validating 하기 위해 사용하는 table에 data를 생성한다.
    Navigation: HRMS Management> HRMS Manager> Processes & Reports> Submit Process & Report> Security List Maintenance
    2. MO Profile Options setup:
    a. MO: Security Profile - 이 profile setting은 MOAC functionality를 활성화 한다.
    b. MO: Default Operating Unit - 이 Operating Unit는 OM forms과 report에서 default가 될 것이며, 이를 clear 하거나 변경하기 위해 LOV를 사용할 수 있다.
    Keep the MO profiles in sync:
    MO: Security Profile은 site와 responsibility level로 setting 할 수 있다.
    MO: Default Operating Unit은 site, responsibility, user level로 setting 할 수 있다.
    Application이 원하는대로 동작되지 않는것을 발견하면 이 profile options의 setting 값을 확인한다.
    3. OM setup:
    R12 upgrade 시 OM Profile에서 migrate 된 새로운 OM System Parameters를 확인:
    Order Management Super User> Setup> System Parameters> Values
    (See <<NOTE 393646.1>>-R12 Readiness Cheat Sheet: Migrated OM Profile Options)
    4. Form에서 hidden field 'Operatin Unit'를 활성화시키고 default folder로 저장:
    Sales Order and Order Organizer forms
    Quick Sales order and Organizer forms
    Sales Agreement forms
    Pricing and Availability form
    Other forms
    Note: Sales Order form에서 hidden field 'Operating Unit'를 'Show' 하기 전에 fotm안에 이 field를 위한 공간을 만들어 놓아야 한다.
    예를 들면 Customer Number field를 짧게 하거나 Operating Unit field로 이 field를 덮어씌울수 있다.
    Reference
    Note 393634.1

    Hi Larry,
    Have you considered adding the exec apps.mo_global.set_policy_context call to your connection's start-up script?
    Tools -> Preferences -> Database -> Filename for connection startup scriptNot the most flexible approach, so I'm not sure if it is appropriate for your application, but just a thought. You might create distinct connection names with different start-up scripts for each org_id.
    Regards,
    Gary
    SQL Developer Team

  • Empty parent-child hierarchy if a date attribute is "1800-01-01 00:00:00.000"!

    I have an Employees dimension that contains a parent-child hierarchy as the supervisor->employees (Org. chart. starts from the CEO to the lowest level of employees). The hierarchy is built on a relation between the employee_id (as the primary and
    surrogate key) and supervisor_id (as a foreign key). There are many other attributes in this dimension one of them is the Termination_Date. The value for Termination_Date for the current employees in the source
    system is "1800-01-01 00:00:00.000" (which is also the default value). The weird thing is that keeping this value in the employee dimension will cause the previously mentioned parent-child hierarchy to show nothing! if I change it to any other
    value or NULL, the hierarchy works fine and shows the expected tree of employees!
    I can change "1800-01-01 00:00:00.000"  to Null in the ETL stage and solve the problem, but I want really to know what causes this ?  why ?!

    I have an Employees dimension that contains a parent-child hierarchy as the supervisor->employees (Org. chart. starts from the CEO to the lowest level of employees). The hierarchy is built on a relation between the employee_id (as the primary and
    surrogate key) and supervisor_id (as a foreign key). There are many other attributes in this dimension one of them is the Termination_Date. The value for Termination_Date for the current employees in the source
    system is "1800-01-01 00:00:00.000" (which is also the default value). The weird thing is that keeping this value in the employee dimension will cause the previously mentioned parent-child hierarchy to show nothing! if I change it to any other
    value or NULL, the hierarchy works fine and shows the expected tree of employees!
    I can change "1800-01-01 00:00:00.000"  to Null in the ETL stage and solve the problem, but I want really to know what causes this ?  why ?!

  • Parent-Child Unbound Transformation from Linear Structure

    Hi ,
    We need to convert the linear people structure into Parent-Child relation with unbounded depth using XQuery. To give in detail, we have the XML schema as
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/ParentChild" xmlns:tns="http://www.example.org/ParentChild" elementFormDefault="qualified">
    <complexType name="People">
    <sequence>
    <element name="id" type="string" />
    <element name="name" type="string" />
    <element name="age" type="string" />
    <element name="parentId" type="string" minOccurs="0" />
    </sequence>
    </complexType>
    <complexType name="Peoples">
    <sequence>
    <element name="people" type="tns:People" maxOccurs="unbounded"></element>
    </sequence>
    </complexType>
    <element name="Peoples" type="tns:Peoples"></element>
    <element name="People" type="tns:People"></element>
    <complexType name="Parent">
    <sequence>
    <element name="id" type="string" />
    <element name="name" type="string" />
    <element name="age" type="string" />
    <element name="child" type="tns:Parent" minOccurs="0" maxOccurs="unbounded" />
    </sequence>
    </complexType>
    <complexType name="Parents">
    <sequence>
    <element name="Parent" type="tns:Parent" maxOccurs="unbounded" ></element>
    </sequence>
    </complexType>
    <element name="Parents" type="tns:Parents"></element>
    <element name="Parent" type="tns:Parent"></element>
    </schema>
    The input structure can appear as
    <?xml version="1.0"?>
    <ns0:Peoples xmlns:ns0="http://www.example.org/ParentChild">
    <ns0:people>
    <ns0:id>1</ns0:id>
    <ns0:name>x</ns0:name>
    <ns0:age>11</ns0:age>
    <ns0:parentId>2</ns0:parentId>
    </ns0:people>
    <ns0:people>
    <ns0:id>2</ns0:id>
    <ns0:name>y</ns0:name>
    <ns0:age>11</ns0:age>
    <ns0:parentId>3</ns0:parentId>
    </ns0:people>
    <ns0:people>
    <ns0:id>3</ns0:id>
    <ns0:name>z</ns0:name>
    <ns0:age>11</ns0:age>
    </ns0:people>
    <ns0:people>
    <ns0:id>5</ns0:id>
    <ns0:name>a</ns0:name>
    <ns0:age>11</ns0:age>
    </ns0:people>
    </ns0:Peoples>
    The response should be like below
    <?xml version="1.0"?>
    <ns0:Parents xmlns:ns0="http://www.example.org/ParentChild">
    <ns0:Parent>
    <ns0:id>3</ns0:id>
    <ns0:name>z</ns0:name>
    <ns0:age>11</ns0:age>
    <ns0:child>
    <ns0:id>2</ns0:id>
    <ns0:name>y</ns0:name>
    <ns0:age>11</ns0:age>
    <ns0:child>
    <ns0:id>1</ns0:id>
    <ns0:name>x</ns0:name>
    <ns0:age>11</ns0:age>
    </ns0:child>
    </ns0:child>
    </ns0:Parent>
    <ns0:Parent>
    <ns0:id>5</ns0:id>
    <ns0:name>a</ns0:name>
    <ns0:age>11</ns0:age>
    </ns0:Parent>
    </ns0:Parents>
    We tried with below XQuery, but it is not resulting as expected.
    (:: pragma bea:global-element-parameter parameter="$peoples" element="ns0:Peoples" location="ParentChild.xsd" ::)
    (:: pragma bea:global-element-return element="ns0:Parents" location="ParentChild.xsd" ::)
    declare namespace ns0 = "http://www.example.org/ParentChild";
    declare namespace xf = "http://tempuri.org/RecursiveParentChild/ParentChild/";
    declare function xf:ParentChild($peoples as element(ns0:Peoples))
    as element(ns0:Parents) {
    <ns0:Parents>
    let $results := <a>{
         for $people1 in $peoples/ns0:people where (not (exists ($people1/*:parentId)))
         return
         <ns0:Parent>
                                  <ns0:id>{ data($people1/ns0:id) }</ns0:id>
                        <ns0:name>{ data($people1/ns0:name) }</ns0:name>
                        <ns0:age>{ data($people1/ns0:age) }</ns0:age>
                             </ns0:Parent>
                   </a>
                   let $result1 :=
                   for $people1 in $peoples/ns0:people where (exists ($people1/*:parentId))
                   return
                        if (data($people1/ns0:parentId) = data($results/ns0:id)) then
                             <ns0:child>
                                  $people1/*
                             </ns0:child>
                        else()
                   return $result1      
    </ns0:Parents>
    declare variable $peoples as element(ns0:Peoples) external;
    xf:ParentChild($peoples)
    Anyone tried similar kind of XQuery?. THere is a possibility that the child node can appear before the parent node, how we can handle that as well?
    Any help on this is appreciated
    Regards
    Venkata Madhu

    You need a recursive function in this situation :
    declare namespace ns0 = "http://www.example.org/ParentChild";
    declare namespace xf = "http://tempuri.org/RecursiveParentChild/ParentChild/";
    declare variable $peoples as element(ns0:Peoples) external;
    declare function xf:getChildren($p as element(ns0:people)) as element(ns0:child)*
      for $c in $peoples/ns0:people[ns0:parentId=$p/ns0:id]
      return <ns0:child>
            <ns0:id>{ data($p/ns0:id) }</ns0:id>
            <ns0:name>{ data($c/ns0:name) }</ns0:name>
            <ns0:age>{ data($p/ns0:age) }</ns0:age>
            { xf:getChildren($c) }
             </ns0:child>
    <ns0:Parents>
      for $p in $peoples/ns0:people[not(ns0:parentId)]
      return <ns0:Parent>
            <ns0:id>{ data($p/ns0:id) }</ns0:id>
            <ns0:name>{ data($p/ns0:name) }</ns0:name>
            <ns0:age>{ data($p/ns0:age) }</ns0:age>
            { xf:getChildren($p) }
             </ns0:Parent>
    </ns0:Parents>

  • Parent Child Data - Populate within a Dropdown

    Hi All ...
    I have a mysql database with the following fields
    ID (Int) - Title (VarChar) - ParentID (Int)
    This table is used to display categories with it's parent.  Categories with the ParentID of 0 means that it is a root category.
    What'm trying to do is query the database and populate all values (with it's parent & child(s)) within a regular html dropdown box.
    So the output of the dropdown whould look like:
    Home
    Home > Sub Cat 1
    Home > Sub Cat 1 > Sub Sub Cat 1
    Home > Sub Cat 1 > Sub Sub Cat 2
    Home > Sub Cat 1 > Sub Sub Cat 3
    Home > Sub Cat 2 > Sub Sub Cat 1
    Home > Sub Cat 2 > Sub Sub Cat 2
    Home > Sub Cat 3
    Home > Sub Cat 4
    Home > Sub Cat 4 > Sub Sub Cat 1
    Home > Sub Cat 5
    Any ideas on how I can accomplish this?
    Many Thanks
    Shafiq

    As far as I know you cannot elegantly handle this sort of datastructure in MySQL (this is based on 5min of googling).  If you had Oracle you could use CONNECT BY PRIOR, and with SQL Server one can use Common Table Expressions to effect much the same thing (except in a pretty clunky fashion, IMO).
    As far as I can tell, MySQL has neither of those options.  You'll need to do some sort of horrific recursive proc, or something like that.  Although I saw references to MySQL not even being able to do that (I didn't check how contemporary those comments were).
    If you can possibly ditch that way of modelling your data - it really doesn't scale so well - have a look at nested set hierarchies:
    http://en.wikipedia.org/wiki/Nested_set_model
    The only modification I make to that is to store the parent with each node too, which makes sibling operations much easier.  Nested sets work really well with hierarchical look-ups though.
    Adam

  • JPA One-To-Many Parent-Child Mapping Problem

    I am trying to map an existing legacy Oracle schema that involves a base class table and two subclass tables that are related by a one-to-many relationship which is of a parent-child nature.
    The following exception is generated. Can anybody provide a suggestion to fix the problem?
    Exception [EclipseLink-45] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
    Exception Description: Missing mapping for field [BASE_OBJECT.SAMPLE_ID].
    Descriptor: RelationalDescriptor(domain.example.entity.Sample --> [DatabaseTable(BASE_OBJECT), DatabaseTable(SAMPLE)])
    The schema is as follows:
    CREATE TABLE BASE_OBJECT(
    "BASE_OBJECT_ID" INTEGER PRIMARY KEY NOT NULL,
    "NAME" VARCHAR2(128) NOT NULL,
    "DESCRIPTION" CLOB NOT NULL,
    "BASE_OBJECT_KIND" NUMBER(5,0) NOT NULL );
    CREATE TABLE SAMPLE(
    "SAMPLE_ID" INTEGER PRIMARY KEY NOT NULL,
    "SAMPLE_TEXT" VARCHAR2(128) NOT NULL )
    CREATE TABLE SAMPLE_ITEM(
    "SAMPLE_ITEM_ID" INTEGER PRIMARY KEY NOT NULL,
    "SAMPLE_ID" INTEGER NOT NULL,
    "QUANTITY" INTEGER NOT NULL )
    The entities are related as follows:
    SAMPLE.SAMPLE_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample to the base class
    SAMPLE_ITEM.SAMPLE_ITEM_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample item to the base class
    SAMPLE_ITEM.SAMPLE_ID -> SAMPLE.SAMPLE_ID - The FK that is used to join the sample item to the sample class as a child of the parent.
    SAMPLE is one to many SAMPLE_ITEM
    The entity classes are as follows:
    @Entity
    @Table( name = "BASE_OBJECT" )
    @Inheritance( strategy = InheritanceType.JOINED )
    @DiscriminatorColumn( name = "BASE_KIND", discriminatorType = DiscriminatorType.INTEGER )
    @DiscriminatorValue( "1" )
    public class BaseObject
    extends SoaEntity
    @Id
    @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "BaseObjectIdSeqGen" )
    @SequenceGenerator( name = "BaseObjectIdSeqGen", sequenceName = "BASE_OBJECT_PK_SEQ", allocationSize = 1 )
    @Column( name = "BASE_ID" )
    private long baseObjectId = 0;
    @Entity
    @Table( name = "SAMPLE" )
    @PrimaryKeyJoinColumn( name = "SAMPLE_ID" )
    @AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ID"))
    @DiscriminatorValue( "2" )
    public class Sample
    extends BaseObject
    @OneToMany( cascade = CascadeType.ALL )
    @JoinColumn(name="SAMPLE_ID",referencedColumnName="SAMPLE_ID")
    private List<SampleItem> sampleItem = new LinkedList<SampleItem>();
    @Entity
    @Table( name = "SAMPLE_ITEM" )
    @PrimaryKeyJoinColumn( name = "SAMPLE_ITEM_ID" )
    @AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ITEM_ID"))
    @DiscriminatorValue( "3" )
    public class SampleItem
    extends BaseObject
    @Basic( optional = false )
    @Column( name = "SAMPLE_ID" )
    private long sampleId = 0;
    Edited by: Chris-R on Mar 2, 2010 4:45 PM

    Thanks for the thoroughness. There was a mistake in moving the code over for the forum. The field names are correct throughout the original source code.
    BASE_OBJECT_ID is used throughout.
    I suspect the problem lies in the one-to-many sampleItem(s) relationship that is based upon the subclassed item class. (The relationship is actually "sampleItems" in the real code and somehow got changed in the move over.)
    The problem may lie in the mapping of the attribute override in the child class to the referencing of the item class from the parent side of the relationship in the Sample class.
    I further suspect this may be specific to Eclipselink based upon other postings I've seen on the web that have similar problems...
    Any thoughts?
    Edited by: Chris-R on Mar 3, 2010 9:56 AM

Maybe you are looking for

  • My macbook air late 2010 won't charge

    I just came from Europe where I was using my Macbook Air on a daily basis, I was using a 2 prong to 2 pin prong (for EU) adapter for my charger. The moment I came back to the USA, I removed the EU adapter and plugged it into the wall for a charge, bu

  • Adobe XI Pro will not open

    Hello, every time I try to open adobe I get an error stating " a program has caused the program to operate correctly, Windows will close the program and notify you if a solution is available". Using Windows 8.1 web browser Pale Moon. I have been runn

  • HT1688 the network connection timed out while updating iphone software

    the network connection timed out while updating iphone software and cannot continue.

  • Is there a way to include a html title, meta description & keywords inside edge animate?

    How do you include a title so when a user adds the html page in their favorites it is something other than untitled. include keywords and description for search engines. Right now I have to load the finished project files in Dreamweaver to insert thi

  • Renaming Multiple Apple TVs in Home Sharing?

    Hopefully this is simple, but I can't find an answer online... I have a straightforward Home Sharing scenario which includes one iTunes library on my iMac, a Gen2 Apple TV in one room, and an older Apple TV in another room. All share as expected with