Master Detail Query automatic query ..Urgent help

In my last question, I asked about how to automatically query a form based on table or master detail and gota good answer. What I actually need to do is also query on the detail, for example
select a.user_id, b.week_ending,b.mon_hrs,b.tues_hrs
from emp_profile a, time_reporting_week b
where user_id = portal30.wwctx_api.get_user
and week_ending = '02-JAN-02'
and a.user_id = b.user_id
So I know that I can query on master table which is emp profile, but I also need to query on week ending which is in detail. Do I change the clause in my form pacjage?Or should I change something in Additional Pl/sql ??

There are two ways to achieve this. Both methods have some drawbacks, so please go through them and choose the one that suits you.
Method 1:
=========
This method does not require altering the form package.
Assumptions : The detail table has a column named WEEK_ENDING.
Steps :-
1> Edit the form and select the query button in the left frame of the master section.
2> For the pl/sql button event handler, choose the action as Query and replace the default code with the following :-
declare
l_where varchar2(4000);
l_where_pre varchar2(4000);
l_where_post varchar2(4000);
l_where_pos integer;
l_week_ending varchar2(4000);
l_lang varchar2(4000);
begin
p_session.get_shadow_value(
p_block_name => 'DETAIL_BLOCK',
p_attribute_name => 'A_WEEK_ENDING',
p_index => 1,
p_value => l_week_ending,
p_language => l_lang);
doQuery;
if l_week_ending is not null then
l_where := p_session.get_value_as_varchar2(
p_block_name => 'DEFAULT',
p_attribute_name => '_DETAIL_WHERE_CLAUSE',
p_index => 1
l_where_pos := instr(l_where,' WHERE ');
l_where_pre := substr(l_where,1,l_where_pos+6);
l_where_post := substr(l_where,l_where_pos+7);
l_where_post := 'week_ending = '||l_week_ending||' and '||l_where_post;
l_where := l_where_pre || l_where_post;
p_session.set_value(
p_block_name => 'DEFAULT',
p_attribute_name => '_DETAIL_WHERE_CLAUSE',
p_value => l_where,
p_index => 1);
QueryDetail(
p_mode => 'QUERY' ,
p_session => p_session);
end if;
end;
3> Click on OK to finish editing the form.
4> Run the form - enter query criteria for the master fields and enter the week-ending criterion in the 1st detail
field under Week Ending. Click the Query button.
Advantage:
You will not lose your changes even if you edit the form later on.
Drawback:
In this method, the querying process will be bit slow as we are querying for the detail records twice.
Once through onQuery and the second time after constructing the new where clause with the additional conditon
for the detail rows.
Method 2
========
This method requires altering the form generated package.
Steps :-
1> In the form package, you will find a onQuery procedure. Towards the end of the procedure, you will find a statement like
"_detail_where_cond" := "_detail_where_cond" || ' WHERE ' || ...
2> As the name of the variable suggests, this where condition will be used while querying the detail block. You need to
add a new clause to this for the week_ending column. Prior to that you need to fetch the shadow value for A_WEEK_ENDING.
3> Your altered code should look something like :-
p_session.get_shadow_value(
p_block_name => 'DETAIL_BLOCK',
p_attribute_name => 'A_WEEK_ENDING',
p_index => 1,
p_value => l_week_ending,
p_language => l_lang);
if l_week_ending is not null then
"_detail_where_cond" := "_detail_where_cond" || ' WHERE WEEK_ENDING = ' || l_week_ending || ' AND ' || --existing code
else
--- use the original code here
"_detail_where_cond" := "_detail_where_cond" || ' WHERE ' || ...
end if;
4> Compile the package body and run the form.
Advantage:
In this method we will be querying the detail rows just once. Unlike in method 1.
Disadvantage:
You will lose your alterations once you create a new version of the form by editing it. You need to recompile the package
after re-introducing your changes.

Similar Messages

  • How to Create Master Detail Page with Query Region

    Hi,
    1. I have a requirement that i need to create a Master(Supplier) Detail(Supplier Site) Page with Query Region.
    Eg. Supplier A in Australia has Supplier Sites X in Melbourne and Y in Sydney.
          Supplier B in US has Supplier Sites C in New York and D in California.
    I need to have Search, based on two fields Supplier Name and Country
    Let us assume i am searching with Supplier Name A then the page should be in the below layout
    Query Region
    Supplier Name : A
    Country:
    Master
    Supplier Name  Country
        A                     Australia
    Detail
    Supplier Site  City
    X                   Melbourne
    Y                   Sydney
    In detail VO it should allow me to add new sites which means i need to connect this VO to database to insert new records
    I have gone few threads and understood that this can be achieved by creating SupplierVO, SupplierSiteVO and a ViewLink.
    But when tried i don't know how can i relate my query region with the Suppleir Table(Header Reagin and Table Using Wizard) and Supplier Site Table(Header Region and Table Using Wizard) i am not sure if i am correct or not, please advise
    2. Also i need to have a Open button in this page and if click the button it should navigate to some other page.
    Please help me how can i achieve this.
    - How to design my page with query region and master detail tables
    - what is the AM and CO code need to be handled
    - What is the code should i write in Open button to open new OAF page.
    Thanks,
    CSK

    Hi,
    This link will be useful for your requirement.
    Master Detail Page using Hide Show and Advanced Table inside Advanced Table - OracleArea51.com
    Let me know if you need more help in this.
    Thanks and Regards,
    Myvizhi

  • Master-Detail relationship and querying back from the detail block

    Hello friends,
    Using oracle forms 6i. I have a multi data block. On the block there is a header and detail section. There is master detail relationship present in these blocks. I have a sequence defined, which generates an auto-number.
    Now in the detail section say I have 4 records all of which are say invoices and I am populating the details about it. On the 'save' button I have defined a logic which generates an auto- number or a unique number for all the 4 records in the detail section. The unique number is shown in the header section in a text-field.
    Now when I query (F11 and then Ctrl+F11) with the help of the unique number i see all the 4 records under it in the detail section. But when I query with the help of one of the 4 records in the detail section it says "fetching more than a single row." I know the same unique number is there for all the 4 records and in the header section I am displaying "number of items displayed" to be 1. That is why the error. But I want that to remain one. How exactly can I develop this functionality of querying the unique number in the header section from the detail block?
    Please help as soon as possible.

    Hi,
    I'd suggest to check this tutorial:
    http://www.oracle.com/technology/obe/obe_as_10g/bi/forms/formsmasterdetailobe.htm
    Having a relationship between data blocks, coordinates dml actions in both, so no coding is needed to save/update/delete records, forms built-ins do the work.
    hope this is useful,
    Hugo

  • Master/Detail data error problem -- Please Help

    Hi All,
    I just created a M/D form for two of my tables (Organization & Contact tables) using wizard with existing sequences to create app. Everything looks great when viewing an existing account and making modifications.
    My problem stems when I try to create a new account, the Organization form comes up. After entering data and hit 'Create' I get error ORA-01403: No data found. Yet it creates account. Is there a way to get both M&D forms up at the same time with no error after entering data?????
    I am too new to know what is going wrong and my manuals do not clarify anything. I'd appreciate any help from a master in Master/Detail forms. :o)
    Thanks,
    d.

    Hi All,
    Just in case anyone has same problem. Since I was not able to get help here I created a tar and we figured that the problem was with the system when I upgraded. System created triggers that were fighting with the sequences that I had manually created.
    Disabled triggers and all is working fine. You still need to watch future applications just in case.
    Later,
    d.

  • Issue with Master Detail relation in OAF page -- Help

    Hi,
    I am developing an OA page with a master detail relation. The detail records are displayed in the subtab region.
    The issue that I am facing is as follows:
    If there are 2 detail records in the detail table, then my page is displaying these 2 records twice i.e.
    Detail Records:
    Header Id Line Id
    2 1
    3 1
    Header Id Line Id
    2 1
    3 1
    If the number of detail record increases, then again the display also increases that many times i.e. 3 records gets displayed thrice.
    Kindly help to figure out the issue.
    Thanks In Advance.

    Hi,
    Take the following actions.
    1. Try to display your records in simple Table and remove it from subtab,
    2. check relations as well, you can delete and re-create all the relations with EOs and VOs and recreate them.
    3. Also check when your VO get popluated that how many rows are there in Detail VO ?
    For example.
    int x = yourViewObject.getRowCount();
    System.out.println("Number of rows in detail view Object"+x);
    Haroon.

  • Important query regd Inheritance.Urgent help please

    Hi,
    I have a query regarding regarding Inheritance
    This is the structure:
    Superclass: Object
    Subclass ListItem extends Object
    Subclass HandleListItem extends ListItem
    My question is:
    Can ListItem be an instance of HandleListItem??

    can ListItem be an instance of HandleListItem??yes - a variable typed as a ListItem can hold an instance of HandleListItem
    ie
    1) some ListItems are HandleListItems
    2) but not all ListItems are HandleListItems
    3) a HandleListItem is always a ListItem

  • Event type linkage automatically deactivated - Urgent help

    Hi,
    I activated the Event type linkage for a PR approval Workflow template (a copy of WS00000038) using t-code SWETYPV, however the Event type linkage got automatically deactivated by the system. I have try to activate again for few times, same thing happen got deactivate automatically, any one have encounter this problem before, please help - Urgent.
    thanks.

    Hi ,
    The mandatory Import parameter might be missing in event container. Event will be deactivated automatically because of these type of errors .
    Please check if you are passing all mandatory import parameters.
    Pls let me know if it worked.
    Regards,
    Ganesh.

  • Custom Master Detail form not working In EBS

    Custom Master Detail form not working In EBS
    Hi all,
    I have two custom tables -- 1) XXX_DIE_Headers
    2) XXX_DIE_LINES
    I developed a Master Detail form based on above tables. XXX_DIE_Headers is the Master Block (Single record) & XXX_DIE_LINES is the detail block ( Multi line block ).
    Yes, I used Appstand,Template.fmb for developing this form. The Master block has three fields out of which Two are required fields and i have given initial value for them.
    As i deployed it in APPS(EBS),everything about it is working fine (insert,delete,master-detail behaviour) except querying.
    When i press F-11 , It pops up a message "Do you want to save changes you have made" Choice - yes,no,cancel.
    I don't want this message to pop up.
    The scenario is :- I open the form.( without entering ) Press F11 . The message Pops up.
    Please give me suggession on how to work it around so as form directly goes to query mode ,without popping the message.
    regards
    ravi

    It seems that you are changing a database value in your form, do you have any changes in WHEN-NEW-FORM-INSTANCE???
    what the form is trying to tell you that you have changed something, do you want to save it?
    I suggest you debug your form and see what's happening step by step.
    Tony

  • Master-Detail Event in Obiee 11g

    Hi all,
    In master report i am using item family.
    Detail report columns are item family,item name, cost and revenue.
    Same analysis i created graph and table view.
    When i am selecting item family in master i am getting correct changes in detail graph but not in table view.
    Pls guide regarding this.
    Thanks in advance.

    Hi,
    Have you correctly specified the channel names in both the views.
    Refer
    http://gerardnico.com/wiki/dat/obiee/master_detail
    http://oraclebiblog.blogspot.com/2011/01/working-with-master-detail-report.html
    Hope this helped/ answered
    Regards
    MuRam

  • Urgent help!!!!!!Regarding the Credit Memo for oracle project customer invoices

    Hi,
    Can somebody help me in this issue
    we have a requirement from the users that they dont want the system to apply
    the credit memo automatically on the invoice when it released from the projects
    Scenario1: Invoice already been paid now they want to create a credit memo,
    system dont allow them to cancel the invoice the only way as per the theory is
    create a negative invoice and adjust it but the issue here is when ever you
    create a negative invoice it creates as invoice not credit memo which will be
    confusing to the users.
    in this case can we use billing extension to create the transaction type as
    credit memo when ever the invoice has negative amount?
    Or let me know if there is a way to perform this step?
    Scenario2: Invoice is created but they dont want to create a credit memo
    against that invoice since it gets applied automatically, the customer
    requirment will be they want to apply the credit memo for any future invoices
    as requested
    Is there a wya to have a credit memo created with out auto applying to an
    invoice, so that user can apply when ever they want
    what is credit memo on accoutn how it works with these above scenarios.
    sicne i tried setting up but the credit meo or concession is getting appled to
    the particular invoice automatically
    need urgent help required on this issue !!!!!
    Regards
    Lavanya

    Hi,
    For Scenario 1 you have two options:
    1) Update the AR transaction type extension for project invoice- Identify negative amount invoice and change the transaction type to project credit memo. This will update the transaction type on negative invoices before they are interfaced to Oracle AR.
    This is preferred option
    2) Update AR invoice Pre-processor to do the same thing.
    There is no standard setup which will allow you to change trx type of negative invoices.
    For Scenario2 - I dont think there is any direct way to create a credit invoice from Projects and keep it unapplied (again, apart from creating a negative amount invoice). You can create a credit memo in AR and use it to apply against future invoices.
    Regards
    Kaushal

  • Data Template---master details query--Help

    Hi
    we are using XML Publisher attached to R12 , we are using data template ( .XML file) in data definition .
    we have a requirement for master details report. for that we have parent query and child query .the data coming to parent query should be the parameter to child query
    Exp-- Parent Query-- select empno from emp
    Child Query --select  * from dept where empno=:p_empno (p_empno =empno from Parent query ) 
    For this requirement we are creating a data template (.XML file) . we are successfully to write for the parent query, but we fails when come to child query. Please help us how it can be wrote in data template . You can send any example related to this issue.

    Parent Query - select empno as emp_no from emp
    Child Query - select * from empno where empno=:emp_no

  • Master-detail automatic query

    How to query the detail block in a
    master-detail form when I change
    any master key field?
    null

    This is not implemented, after you update a record you must click on "Save" button and query again.

  • Master-Detail Form - implementing some thing like Post-Query trigger

    Hi all,
    I am struggling to implement an eqivalent of a post-query trigger in Oracle Forms. Please bear with me as I am trying to explain in detail what the problem is.
    Here is my situation.
    I have three tables EMP, DEPT and LOCATION. I created a Master/Table pages on EMP and DEPT.
    Basic relationships.
    Each LOCATION has one or more DEPTs; Each DEPT is at one and only one LOCATION.
    Each DEPT has one ore more EMPs; Each EMP is assigned to only and only DEPT.
    Not getting too complicated, here are the table layouts:
    LOCATION:
    ID number(10,0) not null,
    NAME varchar2(20) not null
    DEPT
    ID number(10,0) not null,
    NAME varchar2(20) not null,
    LOC_ID number (10,0) not null foreign key from LOCATION
    EMP
    ID number(10,0) not null,
    NAME varchar2(20) not null,
    DEPT_ID number (10,0) not null foreign key from DEPT
    Assume I have all the constraints, BIU triggers, sequences defined properly.
    I am using the APEX page wizard to create a Master/Detail Form on DEPT and EMP. The first page is the Master Report on DEPT. I want to display the Location Name on this page also. Because the Master Report allows
    you to change the query, I was able to add the Location Name as part of the
    query. This was very simple.
    Select a.name "Department_Name",
    b.name "Location"
    from dept a, location b
    where a.loc_id = b.id
    Moving on, In the Master Detail Form, I would like to get the Location Name as part of the first Region (Dept Region).
    In this region, I would like to include the Location Name also. So my first region on the Master Detail form includes:
    Dept Id: ________
    Dept Name: _______
    Location Name: __________
    As Region are automatically populated using using a Fetch Row from EMP table (Automated Row Fetch) on an After Header process point, I don't have a way of including the Location as part of query. So I created a Region level Item called Location Name, made it Display only.
    In the old SQL*Forms, or Oracle Forms days, I used to use a Post-Query trigger, or Post-Change trigger to fire on the Loc_Id column to populate the Location Name. Simple fetch like:
    Select name
    into :P80_location_name
    from location
    where loc_id = :P80_loc_id
    However, I am struggling to implement some thing simple like this in APEX. Tried creating a processes, computatations etc, but nothing is working.
    I have seen some previous responses to fetching values from a foreign table
    using a button or AJAX script, but this should be very basic. What am I
    missing here?
    Appreciate any insights.
    Thanks.
    John

    Hi John,
    I'm not too familiar with the post-query triggers in Oracle Forms, but the use of a List of Values (LOV) on your LOCATION table might do the trick for you. If you create a dynamic LOV based on your LOCATIONS table, it can then be referenced by the LOC_ID item on the Master-Detail page, to display the Location Name. You could try doing the following:
    1. Create a new dynamic LOV, LOCATIONS, using a query similar to the following:
    select Name d, ID r
    from LOCATION
    order by 1
    2. Edit the "Create" button on the Master report page, and in the "Optional URL Redirect" section set "Request" to CREATE. Click Apply Changes, to save the setting.
    3. Edit the LOC_ID item on your Master-Detail page, and set the following:
    * in the "Name" region change the "Display As" setting to Select List
    * in the "Label" region change the Label to Location Name.
    * in the "List of Values" region set the "Named LOV" to LOCATIONS
    * in the "Read Only" section, set the condition to Request != Expression 1, and set Expression 1 to CREATE.
    Click Apply Changes to save the settings.
    When you run the pages now, the Location Name field will appear as Read-Only when editing a selected Master row. The item will appear as a Select List when the user clicks "Create" on the Master page, to create a new Master row.
    I hope this helps.
    Regards,
    Hilary

  • Master Detail Form - How 2 update a field in the Detail form using a query?

    Hello,
    I have a master detail form with, each master record having a fixed(6) number of detail records. One of the fields in the detail record is the PART_DESCRIPTION field. I am trying to update this field by querying Table_X. TABLE_X is in the format of (desciption id, description). Description id runs from 1 to 6.
    When the form displays, the PART_DESCRIPTION field for the 6 detail records needs to be automatically populated with the six values of description stored in Table_X. How can this be done?
    Tried using session storage objects, but made no headway.
    Would greatly appreciate pointers on how to go about doing this.
    Thanks.
    Dev

    If you are on a Portal Version lesser than 3.0.9.8.3, then please try the following to populate
    the PART_DESCRIPTION field.
    Steps:-
    1> Edit the form and go to the Additional PL/SQl section and put the following code in the
    "...after displaying the page area" :-
    declare
    type t_vc_arr is table of varchar2(4000) index by binary_integer;
    l_arr_desc t_vc_arr;
    l_form_name varchar2(200);
    l_form_state varchar2(500);
    begin
    l_form_name := p_session.get_module().get_name();
    l_form_state := p_session.get_value_as_varchar2(
    p_block_name => 'MASTER_BLOCK',
    p_attribute_name => '_FORM_STATE'
    if l_form_state = 'QUERY_AND_SAVE' then
    select description
    bulk collect into l_arr_desc
    from <schema>.table_x;
    htp.p('
    <script>
    var descArr = new Array();
    var Fidx = 1;
    var formObj = document.WWVM'||p_session.get_id()||';
    var fieldName = "'||l_form_name||'.DETAIL_BLOCK.PART_DESCRIPTION.0";
    for i in 1..l_arr_desc.count loop
    htp.p('descArr['||to_char(i-1)||']="'||l_arr_desc(i)||'";');
    end loop;
    htp.p('
    for (var i=0; i < formObj.length; i++){
    if (formObj.elements.name == fieldName+Fidx){
    formObj.elements[i].value = descArr[Fidx-1];
    ++Fidx;
    htp.p('</script>');
    end if;
    end;

  • Master-details query to XML file?

    Hi:
    I'm new in XML and Oracle. I want to create XML file from two tables (master-details).
    I made a small serach and tried some examples:
    Say we have these tables:
    CREATE TABLE "TEST_XML"
    (     "ID" NUMBER,
         "NAME" VARCHAR2(15),
         "AMOUNT" NUMBER,
         CONSTRAINT "TEST_XML_PK" PRIMARY KEY ("ID") ENABLE
    CREATE TABLE "TEST_XML2"
    (     "ID2" NUMBER,
         "NAME2" VARCHAR2(20),
         "AMOUNT2" NUMBER
    ALTER TABLE "TEST_XML2" ADD CONSTRAINT "TEST_XML2_FK" FOREIGN KEY ("ID2")
         REFERENCES "TEST_XML" ("ID") ENABLE
    INSERT INTO TEST_XML VALUES (1,'A',50);
    INSERT INTO TEST_XML VALUES (2,'B',30);
    INSERT INTO TEST_XML VALUES (3,'C',70);
    INSERT INTO TEST_XML2 VALUES (1,'AA',10);
    INSERT INTO TEST_XML2 VALUES (1,'AB',20);
    INSERT INTO TEST_XML2 VALUES (1,'AC',20);
    INSERT INTO TEST_XML2 VALUES (2,'BA',10);
    INSERT INTO TEST_XML2 VALUES (2,'BB',20);
    INSERT INTO TEST_XML2 VALUES (3,'CA',20);
    INSERT INTO TEST_XML2 VALUES (3,'CB',40);
    INSERT INTO TEST_XML2 VALUES (3,'CC',10);
    I want a query to create XML file contains data from TEST_XML table and for each row the related data from TEST_XML2 table.
    I did some tries (working in iSQL*PLUS):
    SET SERVEROUTPUT ON
    DECLARE
    v_ctx DBMS_XMLGEN.ctxType;
    v_file Utl_File.File_Type;
    v_xml CLOB;
    v_more BOOLEAN := TRUE;
    BEGIN
    -- Create XML document from query.
    v_ctx := DBMS_XMLGEN.newContext('select id,name,amount,cursor (select id2,name2,amount2 from test_xml2 t2 where t2.id2=t1.id) val from test_xml t1');
    DBMS_XMLGEN.setMaxRows(v_ctx, 10);
    DBMS_XMLGEN.setRowsetTag(v_ctx, 'CLAIM');
    -- Output XML document to file.
    v_file := Utl_File.FOpen('TEST_DIR', 'test1.xml', 'w');
    WHILE v_more
    LOOP
    v_xml := DBMS_XMLGEN.GetXML(v_ctx,0);
    EXIT WHEN dbms_xmlgen.getNumRowsProcessed(v_ctx) =0;
    Utl_File.Put(v_file,v_xml);
    END LOOP;
    Utl_File.FClose(v_file);
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,255));
    Utl_File.FClose(v_file);
    END;
    But hte output wasn't as I wanted:
    <CLAIM>
    <ROW>
    <ID>1</ID>
    <NAME>A</NAME>
    <AMOUNT>50</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AA</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AB</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AC</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    <ROW>
    <ID>3</ID>
    <NAME>C</NAME>
    <AMOUNT>70</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CA</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CB</NAME2>
    <AMOUNT2>40</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CC</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    <ROW>
    <ID>2</ID>
    <NAME>B</NAME>
    <AMOUNT>30</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>2</ID2>
    <NAME2>BA</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>2</ID2>
    <NAME2>BB</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    </CLAIM>
    Notice that for each details (from TEST_XML2) there is <VAL> tag which I don't need beside i want a query which is applicable on all environments.
    May anyone help me please......
    Regards,
    Saad

    The following looks like it produces your desired output. I used the WITH to simulate your two tables so I didn't have to CREATE them. This runs on 10.2.0.1. I'm not sure what bugs you are referring to as SQL/XML is stable in 10g that I have seen. I'm sure some bugs exist somewhere in it, just not with this usage. Just start with the SELECT statement to run on your system.
    WITH test_xml AS
    (SELECT 1 ID, 'A' name, 50 amount FROM DUAL UNION ALL
    SELECT 2, 'B', 30  FROM DUAL UNION ALL
    SELECT 3, 'C', 70  FROM DUAL),
    test_xml2 AS
    (SELECT 1 ID2, 'AA' name2, 10 amount2 FROM DUAL UNION ALL
    SELECT 1, 'AB', 20  FROM DUAL UNION ALL
    SELECT 1, 'AC', 20  FROM DUAL UNION ALL
    SELECT 2, 'BA', 10  FROM DUAL UNION ALL
    SELECT 2, 'BB', 20  FROM DUAL UNION ALL
    SELECT 2, 'BC', 20  FROM DUAL UNION ALL
    SELECT 3, 'CA', 20  FROM DUAL UNION ALL
    SELECT 3, 'CB', 40  FROM DUAL UNION ALL
    SELECT 3, 'CC', 10  FROM DUAL)
    SELECT XMLElement("CLAIM",
             XMLAgg(
               XMLElement("ROW",
                 XMLForest(id "ID",
                           name "NAME",
                           amount "AMOUNT"),
                 (SELECT XMLAgg(XMLElement("VAL_ROW",
                                 XMLForest(id2 "ID2",
                                           name2 "NAME2",
                                           amount2 "AMOUNT2")))
                          FROM test_xml2 t2
                         WHERE t2.id2=t1.id)
      FROM test_xml t1This solution works in any environment where you can issue a SQL statement from, be it SQL*Plus, PL/SQL, Java, etc.

Maybe you are looking for

  • How to setup iChat in a office

    How to setup iChat in a office that using Office Communicator as a IM ?

  • 2007.08-2 Isos released, installation feedback

    Hi Arch community, Arch Linux 2007.08-2, "Don't Panic" has been released. This is the first release to use our new repo layout. There are two ISOs, ftp and core. Changelog: GENERAL: - kernel 2.6.22.9 usage - disabled arch_addons hook by default, it i

  • Strange Leopard happenings

    I have been having a lot of trouble since I installed Leopard onto the new 20" I-Mac I got at xmas. Discovered that none of the programs show or will allow the creation of PDF files (Word etc.) even tho they all worked when the same computer was stil

  • Placing .indd into .indd Document

    I have Tool Manuals that I am producing and when I place a .indd file into one of these InDesign documents the formating is not the same size. I can build two .indd files with the exact same info with the same margins, paragraph styles, etc. in both.

  • Exclusion of members..

    In the EPM 10NW report, I need to exclude certain entity members from the display. In the 'report editor' I am using the 'Exclude members' option in this regard. These members are excluded from the report display, but still showing up in the hierarch