Record Group functions - Problerms with a function Get_Group_Selection

Anywone knows how to delete a record from a record group, i have this code below on the trigger KEY-DELREC, every time i delete a record this code is execute. The problem here is that i whant to delete a row in a record group but , i can't use the function Get_Group_Selection, to find the number of the row i want to delete, when i use the function Get_Group_Selection, it gives me the error FRM-41087 .
Can aywone help me with that , it's urgent!!
Thanks
DECLARE
ora_err NUMBER;
rg_id RECORDGROUP;
the_Rowcount NUMBER;
gc_id1 GroupColumn;
gc_id2 GroupColumn;
v_art_grp_no number(3);
v_descr VARCHAR2(20);
v_art_grp_no2 number(3);
v_descr2 VARCHAR2(20);
v_ctn NUMBER := 0;
v_row NUMBER;
begin
rg_id := Find_Group('REG_REPAIRS_COMPONENTS');
the_Rowcount := Get_Group_Row_Count( rg_id );
--** Make sure the column name specified exists in the ** record Group. */
gc_id1 := Find_Column('REG_REPAIRS_COMPONENTS.ART_GRP_NO');
gc_id2 := Find_Column('REG_REPAIRS_COMPONENTS.DESCR');
FOR j IN 1..the_Rowcount LOOP
     v_ctn := Get_Group_Selection(rg_id,j);
     v_art_grp_no := Get_Group_Number_Cell(gc_id1,v_ctn);
v_descr := GET_GROUP_CHAR_CELL(gc_id2,     v_ctn );
if UPPER(v_descr) = UPPER(:system.cursor_value) and UPPER(v_art_grp_no) = UPPER(:repairs_components.art_grp_no) then
     Delete_Group_Row('REG_REPAIRS_COMPONENT',      v_ctn);
     delete_record;
     end if;
     END LOOP;
end;

Thanks for the HELP!
But now i have an other problem that is when i invoke the when-validate item trigger it searchs the field for a value that´s is equal to value in a record group and if it finds it, it raises
raise_form_trigger_failure and displays a messagem, it works fine but if a press the button save or back it displays the message and after if i press the default button to delete again it doesn´t work .

Similar Messages

  • How to pass record Group from Forms with DATA_PARAMETER to Reports Server

    How to pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    When we use products on run time we are using data_parameter for passing record Groups to reports via run_product but now we have to use application server and reports server for same reports.
    We met with <FRM-41214 Unable to run reports> for passing DATA_PARAMETER to reports server when used RUN_REPORTS_OBJECT.
    How can we pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    Thanks,
    Arif

    Hi Mandeep,
    Could you please tell me how can i pass data parameter from forms to report through run_product.

  • How to Pass Record Group to Reports Server ?

    How to pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    When we use products on run time we are using data_parameter for passing record Groups to reports via run_product but now we have to use application server and reports server for same reports.
    We met with <FRM-41214 Unable to run reports> for passing DATA_PARAMETER to reports server when used RUN_REPORTS_OBJECT.
    How can we pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    Thanks,

    how come the online help in forms 10g says you can?
    or am I missing something.
    there is a section on it.
    >
    Passing Record Groups to Reports or Graphics
    You can pass a record group to Reports or Graphics as a DATA parameter. This DATA parameter is a special type of parameter that gives a signal to the integration code to substitute the contents of the record group whose name you give for the results of the query named by the query name you indicate.

  • Which two statements define a Static Record Group?

    Hi all
    I read this question and I do not know the answer
    the question is
    Which two statements define a Static Record Group? (Choose two)
    A. The Record Group can be created only at run time.
    B. The Record Group is not associated with a query.
    C. The Record Group can be created and modified only at design time.
    D. The Record Group can be created and modified at design time or at run time.
    E. You can modify the structure of this Record Group by adding columns and rows at run time.
    F. You can modify the structure of this Record Group by associating it with a query at run time.

    Types of record group, either Static or Query:
    Static     Specifies that the record group is constructed of explicitly defined column names and column values.
    The values of a static record group are specified at design time and cannot be changed at runtime.
    Query     Specifies that the record group is associated with a SELECT statement, and thus can be populated dynamically at runtime.
    When you select this option, enter the SELECT statement in the multi-line field provided, then choose Apply.
    So answers B and C
    From Forms Help

  • Can't use function in creating record group

    Gurus,
    This question is for developers. Is this true one can't use
    function in creating record group. I am using form5.
    thanks,
    ZW

    I figured out the issue... they changed the way Group Calls are limited.
    Here's a full explaination - and a suggestion for a behavior fix: http://community.skype.com/t5/Windows-desktop-client/Please-Fix-Group-Video-Voice-Calling-Limit-Beha...
    Long story short, you can't do a video calling at all if the group has more than 10 people in it total (including you).
    Also, you can't do voice calling in groups with more than 25 people.
    Text chats are limited to 300 people (or so I've been told by Skype employees). I've been in a chat with over 100 participants though so I know it goes that high at least.

  • Issue with not a single-group group function error

    Hello PL/SQL Gurus,
    I am using Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production version and
    Once I am using the following query –
    SELECT s.sym,
    t.tag_trade_method trade_method,
    astd.tag_trade_sector,
    iss.gics_sector_dsc sector,
    d.date_dt trade_date,
    c.wmc_curcy_cd_alpha curcycode,
    amd.brkr_nm,
    SUM(atdf.notional_amt) trd_notional,
    SUM(atdf.trd_qty) trd_qty,
    ard.buy_sell_ind,
    td.person_init
    FROM alloc_tran_det_fact atdf,
    date_dim d,
    alloc_trade_tag_dim t,
    security_dim s,
    currency_dim c,
    person_dim td,
    access_method_dim amd,
    alloc_sec_tag_dim astd,
    alloc_ref_dim ard,
    issuer_dim iss
    where atdf.alloc_trd_tag_dim_key = t.alloc_trade_tag_dim_key AND
    atdf.alloc_sec_tag_dim_key = astd.alloc_sec_tag_dim_key AND
    ard.alloc_ref_dim_key = atdf.alloc_ref_dim_key AND
    atdf.isr_dim_key = iss.isr_dim_key AND
    atdf.trd_dt_key = d.date_dim_key AND
    atdf.sec_dim_key = s.sec_dim_key AND
    t.tag_valid_trade_flg = 'Y' AND
    atdf.locl_curcy_flg = 'Y' AND
    d.date_dim_key BETWEEN 20120405 AND 20120405 AND
    c.curcy_dim_key = atdf.curcy_dim_key AND
    td.person_dim_key = atdf.trdr_dim_key AND
    atdf.exec_brkr_dim_key = amd.access_method_dim_key AND
    amd.level_cd = 'B'
    and t.tag_trade_method in('ALGO','CAPITAL','DMA','NATURAL','WORKING')
    then it throw the error –
    ORA-00937: not a single-group group function
    If I am using something like –
    SELECT s.sym,
    t.tag_trade_method trade_method,
    astd.tag_trade_sector,
    iss.gics_sector_dsc sector,
    d.date_dt trade_date,
    c.wmc_curcy_cd_alpha curcycode,
    amd.brkr_nm,
    SUM(atdf.notional_amt) trd_notional,
    SUM(atdf.trd_qty) trd_qty,
    td.person_init
    FROM alloc_tran_det_fact atdf,
    date_dim d,
    alloc_trade_tag_dim t,
    security_dim s,
    currency_dim c,
    person_dim td,
    access_method_dim amd,
    alloc_sec_tag_dim astd,
    issuer_dim iss
    WHERE atdf.alloc_trd_tag_dim_key = t.alloc_trade_tag_dim_key AND
    atdf.alloc_sec_tag_dim_key = astd.alloc_sec_tag_dim_key AND
    atdf.isr_dim_key = iss.isr_dim_key AND
    atdf.trd_dt_key = d.date_dim_key AND
    atdf.sec_dim_key = s.sec_dim_key AND
    t.tag_valid_trade_flg = 'Y' AND
    atdf.locl_curcy_flg = 'Y' AND
    d.date_dim_key BETWEEN 20120102 AND 20120401 AND
    c.curcy_dim_key = atdf.curcy_dim_key AND
    td.person_dim_key = atdf.trdr_dim_key AND
    atdf.exec_brkr_dim_key = amd.access_method_dim_key AND
    amd.level_cd = 'B'
    and t.tag_trade_method in('ALGO','CAPITAL','DMA','NATURAL','WORKING')
    GROUP BY t.tag_trade_method,
    d.date_dt,
    c.wmc_curcy_cd_alpha,
    td.person_init,
    amd.brkr_nm,
    astd.tag_trade_sector,
    iss.gics_sector_dsc
    then it works fine. I know that due to aggeregate functions we need to use Group By, but why to put Group By on different non aggregate columns,
    As my intension is to fetch the records for defined date range Group By Symbol (s.sym), Kindly help me with this. 
    Thanks to all of you in advance for providing you valuable time and efforts.
    Edited by: user555994 on May 11, 2012 2:20 AM

    You do need to group by these columns
    t.tag_trade_method,
    d.date_dt,
    c.wmc_curcy_cd_alpha,
    td.person_init,
    amd.brkr_nm,
    astd.tag_trade_sector,
    iss.gics_sector_dsc
    as they don't have aggregate functions applied to them.

  • JDBC 8.1.6.0.1 Bug with grouping function

    Hi,
    I found a bug in the JDBC 8.1.6.0.1 driver, concerning the new grouping functionality of Oracle 8.1.6. Look at the following code fragment:
    String cSelect = "SELECT DACO_VU_NAME AS DIM1, ' ' AS DIM2, TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') AS DIM_DATE, GROUPING(DACO_VU_NAME) AS DIM1GROUP, GROUPING(' ') AS DIM2GROUP, GROUPING(TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm')) AS DIM_DATEGROUP, sum(DACO_BRUTTOBETRAG_TX) AS VALUE FROM DATENCONTAINER GROUP BY CUBE (DACO_VU_NAME, '-', TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') ) ORDER BY 1,2,3";
    try {
    System.out.println("SELECT: " + cSelect);
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery(cSelect);
    while (rset.next()) {
    String cTest1 = rset.getString("DIM1");
    String cTest2 = rset.getString("DIM2");
    String cTest3 = rset.getString("DIM_DATE");
    String cChar1 = rset.getString("DIM1GROUP");
    String cChar2 = rset.getString("DIM2GROUP");
    String cChar3 = rset.getString("DIM_DATEGROUP");
    System.out.println(cTest1 + "\t" + cTest2 + "\t" + cTest3 + "\t" + cChar1 + "\t" + cChar2 + "\t" + cChar3);
    }When I compile this with the mentioned JDBC version and run it with java 1.2.2 (JDeveloper 3.1), i get the following output:
    Ahrend GmbH & Co. KG 200003 0 0 0
    Ahrend GmbH & Co. KG 200003 1 0 0
    Ahrend GmbH & Co. KG 200004 0 0 0
    Ahrend GmbH & Co. KG 200004 1 0 0
    Ahrend GmbH & Co. KG null 0 0 1
    Ahrend GmbH & Co. KG null 1 0 1
    null 200003 0 1 0
    null 200003 1 1 0
    null 200004 0 1 0
    null 200004 1 1 0
    null null 0 1 1
    null null 1 1 1As you can see, the grouping columns are mixed up. In this example, everywhere a normal row shows a "null" value, a corresponding grouping row should show a "1", but as you can see, for the last 6 rows, the ones are not in the first, but in the second grouping row.
    When I compile the example with the Oracle 8.1.5 JDBC driver, I get the following, correct, output:
    Ahrend GmbH & Co. KG 200003 0 0 0
    Ahrend GmbH & Co. KG 200004 0 0 0
    Ahrend GmbH & Co. KG null 0 0 1
    Ahrend GmbH & Co. KG 200003 0 1 0
    Ahrend GmbH & Co. KG 200004 0 1 0
    Ahrend GmbH & Co. KG null 0 1 1
    null 200003 1 0 0
    null 200004 1 0 0
    null null 1 0 1
    null 200003 1 1 0
    null 200004 1 1 0
    null null 1 1 1The special thing about this example is, that I use a constant row for grouping (row 2). If you use a normal database row, everything works fine with 8.1.6.0.1, but nevertheless, this should be a bug.
    Any comments on this are highly appreciated, since I need the JDK 1.2 for the application and I didn't find a working Oracle 1.2 JDBC version.
    Thanks,
    Thorsten.

    Patches can be obtained from an Oracle Support Services technical analyst.
    null

  • Error in nested group function used with column name.

    Hi Team,
    If i used nested group function with column name its not working. Could you please any one suggest me.
    How to use it.
    Regards,
    Venkat.
    Please find Spool ........
    SQL> select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name,CNT;
    select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    ERROR at line 1:
    ORA-00937: not a single-group group function
    SQL> select max(max(CNT)) from(select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name;
    MAX(MAX(CNT))
    605

    Venkat wrote:
    Hi Sayan
    Its giving output like below, but not given maximum CNT.
    SQL> select user_name,max(CNT)from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name;
    USER_NAME MAX(CNT)
    BANES_LERG 6
    VENE_USER 8
    USER3 339
    DBUS 106
    VEL_USER 37
    SYS 597
    6 rows selected.Check it - Re: Error in nested group function used with column name.
    and previous post

  • How to display single row column with nested group function

    SQL> select deptno, Max(sum(sal)) SalSum
    2 from emp
    3 group by deptno;
    select deptno, Max(sum(sal)) SalSum
    ERROR at line 1:
    ORA-00937: not a single-group group function
    Can you please the Help me to get the Max(sum(sal)) with Deptno ......

    select deptno, sum(sal) SalSum
    from emp
    group by deptno;The ablove query will give only one value for SALSUM for a department. So there is no meaning on applying MAX on this for a department..
    What are you trying to achieve?
    This?
    select max(salsum) salsm,max(deptno) keep(dense_rank first order by salsum desc) deptno
    from(
    select deptno, sum(sal) SalSum
    from emp
    group by deptno);Edited by: jeneesh on Sep 4, 2012 6:00 PM

  • How to use group function in insert or update

    Hai All
    How can we use group function in insert or update statement
    I am generating an attendance so i have different set of timing for example
    0800,1200,1230, 1700 and i need to insert into these data into table with min value to intime and max value to
    outtime and othere to inertval time in or out
    Pls tell me with some example
    For example
    For INSERT
    insert into T2 (barcode,empcode,intime,attend_date)
                   values(r2.cardn,r2.enpno,MIN(r2.ptime),r2.pdate);
    For UPDATE
    update dail_att set outtime= MAX(r2.ptime) where empcode=r2.enpno and barcode=r2.cardn and
    attend_date=r2.pdate;
    Here instead of where i need to use having so pls tell how to use
    Thanks & Regards
    Srikkanth.M

    Hai Man
    R2 is not a table name its a record
    Let me explain clearly
    I have to generate daily attendance for lot of employees So i have two table t1 and t2
    T1 consist of three column empno,date,time
    T2 consist of empno,name,date,intime,outtime,intrin,introut
    So now i need to give the T1 Min value Of time to T2 Intime and T1 Max value of Time to T2 Outtime fields so there so many records while i am using
    max(time) it gives the max value of all so i seperated by group function so now i have an error in subquery ie it is an single row subquery so i need to use multiple row subquery how i can use multiple row subquery in update statement
    Thanks In Advance
    Srikkanth.M

  • Is there a way to create a group function?

    I want to create a group function like max,sum,count for a
    pl/sgl function. This group function will be something like max
    (let's call it max2) but it will return the second highest value
    of a group.
    Any ideas anyone?

    Since you might not completely understand what i mean i give you
    this example:
    the ranktest table is:
    A     B     C
    a     b     1
    a     b     1
    a     b     5
    a     b     12
    a     b     7
    b     c     1
    b     c     3
    b     c     2
    b     c     4
    b     c     8
    c     d     4
    c     d     3
    c     d     6
    c     d     1
    c     d     2
    c     d     12
    c     d     7
    c     d     3
    a     b     5
    c     d     12
    SELECT A,B,C
    FROM (
    SELECT A,B,C, dense_rank() over (
    PARTITION BY A,B
    ORDER BY C desc) AS sorted_c
    FROM ranktest a)
    WHERE sorted_c = 2
    -- this way we get the c column to have the 2nd highest value
    -- for each set of A and B
    --RESULT
    a b 7
    b c 4
    c d 7
    SELECT a.A,a.B, sum(a.C), count(a.C)
    FROM ranktest a
    GROUP BY a.A,a.B
    -- this way we get the group functions to work on two of the
    -- columns
    --RESULT
    a b 31 6
    b c 18 5
    c d 50 9
    The result that i want is
    a b 31 6 7
    b c 18 5 4
    c d 50 9 7
    My question is can this be done in a single select statement. I
    know it can be done with an intermediate step (of the creation
    of a temp table).
    Plus i would like to ask the experts, would a single select
    statement be more efficient?
    NOTE: the tables and data are just test data. The real tables
    and data and the select query are different. The real ranktable
    has about 1 million records. That's why i am worried about
    efficiency.

  • Error while using group function

    Oracle forms6i
    Hai
    While i am compile my coding it compile successfully, but when i tried to executes i shows error in group function
    my coding is
    if (cnt<>0 ) then
    select BARCODE,INTIME,OUTTIME into today_bar,today_in,today_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate;
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate;
    else
    if (cnt2<>0 ) then
    select INTIME,OUTTIME into yest_in,yest_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate-1;
    if(yest_in is not null and yest_out is null) then
    update dail_att set outtime =max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate);
    end if;
    else
    if :bartime between 0100 and 0630 then
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate-1);
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,:min(bartime),:bardate);
    end if;     
    end if;
    end if;
    while i am trying to this groupfunction it throws error while i use having tell me how to use group function and where
    to use
    Regadrs
    Srikkanth.M

    Hai sir
    I had a table that contain fields
    EMPCODE NUMBER
    EMPNAME VARCHAR2(25)
    BARCODE VARCHAR2(25)
    INTIME VARCHAR2(25)
    OUTTIME VARCHAR2(25)
    INTRTIMEIN VARCHAR2(25)
    INTROUTTIME VARCHAR2(25)
    PERTIMEIN VARCHAR2(25);
    PERTIMEOUT VARCHAR2(25);
    ATTEND_DATE DATE ;
    Consider that a table with 6 fields ie timein,intrtimein,pertimein,pertimeout,intrtimeout,timeout
    I have generating a attendance table and a table contain 6 various times for an employees and we need to arrange it in order
    0815,0816,1230,1250,1645,1646
    If 0815 is the starting time then timein ie mintime
    0816 stored to be in intrtime
    then1250 then it stored in pertimein
    then 1230 then it stored in pertimeout
    then 1645 stored in intrtimeout
    then 1646 stored in timeout
    I tried with max and min function but its not working properly pls tell me some solutions
    Thanks & Regards
    Srikkanth.M

  • ORA-00978  without group function

    I've experienced a strange problem with oracle 11g.
    I've retrieved the oracle exception ORA-00978 even if there was no group function in my query.
    I supposed was a problem in the optimizer so I rebuild the tables statistics, after that the query was execute successfully.
    Does anyone has an idea what the problem is?
    Is possible that a bug exists in the 11g optimizer?
    My oracle version is:
    Oracle Database 11g Enterprise Edition 11.1.0.6.0 64bit Production
    the query i tried is:
    SELECT *
    FROM TBCALENDAR Cal,
    VWCALENDARACTIVITY CA,
    VWSE R,
    TBSCHEDULERPARTITION P,
    TBREGION REG,
    TBRESOURCE RES ,
    TBZIPCITY z
    WHERE Res.id=Cal.RESOURCE_ID
    AND R.RESOURCE_ID=RES.ID
    AND Cal.ACTIVITY_ID=CA.ID
    AND CA.SCHEDULING=1
    AND Cal.SCHEDPARTITION_ID IN
    (select item.PARTITION_ID
    from tbidcprofile prof,
    tbidcpartitem part,
    tbschedpartitem item
    where prof.USERPROFILE_ID=4
    and prof.IDCPARTITION_ID=part.PARTITION_ID
    and part.BUSINESSUNIT_ID=item.BUSINESSUNIT_ID
    and part.REGION_ID=item.REGION_ID )
    AND TRUNC(Cal.START_DT)=trunc(sysdate)
    AND P.ID=Cal.SCHEDPARTITION_ID
    AND REG.ID(+)=Cal.WORKREGION_ID
    AND Z.GEOLOCATION_ID(+)=Cal.HOMEGEOLOC_ID;
    VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
    I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
    Thanks
    Renzo

    user479513 wrote:
    VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
    I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
    What are the views definition ?
    Nicolas.

  • Not a single-group group function very urgent

    HI,
    select sum(avg(wait_to))+sum(avg(idle))+sum(avg(users))+sum(avg(system)) from system_cpu
    where hostid='DSCP02469' group by cpuid
    this query is working
    but i want cpuid group to be displayed
    so i wrote query like this.
    select cpuid,sum(avg(wait_to))+sum(avg(idle))+sum(avg(users))+sum(avg(system)) from system_cpu
    where hOstid=' ' group by cpuid it is throwing a error
    not a single-group group function.
    how can get sum of avg of colums,column based on some coloum
    group by column
    id,sum(avg( )) i have to get
    please give me solution.
    send me mail to [email protected]

    hi,
    thanku for immediate reply but
    if i do that
    select cpuid, a+b+c+d total_value from (select cpuid,
    sum(avg(wait_to)) a, sum(avg(idle)) b,sum(avg(users)) c,sum(avg(system)) d
    from system_cpu where hostid='DSCP02469' group by cpuid)
    SQL> /
    select cpuid, a+b+c+d total_value from (select cpuid,
    ERROR at line 1:
    ORA-00937: not a single-group group functionelse
    select cpuid, a+b+c+d total_value from (select
    sum(avg(wait_to)) a, sum(avg(idle)) b,sum(avg(users)) c,sum(avg(system)) d
    from system_cpu where hostid='DSCP02469' group by cpuid)
    SQL> /
    select cpuid, a+b+c+d total_value from (select
    ERROR at line 1:
    ORA-00904: "CPUID": invalid identifier2)
    can we use select in select case
    can we use select sal, case when sal then select * from emp like this
    with regards
    shannu sarma

  • Nested group function without group xmlagg

    I am getting nested group function without group by xmlagg when using the xmlagg function inside another xmlagg function. Find the table structure and sample data here,
    CREATE TABLE "TEST_TABLE"
       ("KEY" NUMBER(20,0),
        "NAME" VARCHAR2(50 ),
        "DESCRIPTION" VARCHAR2(100 )
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (1,'sam','desc1');
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (2,'max','desc2');
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (3,'peter',null);
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (4,'andrew',null);
    select
            XMLSerialize(document
            xmlelement("root",
             xmlagg(
               xmlelement("emp"          
               , xmlforest(Key as "ID")          
               , xmlforest(name as "ename")
               , xmlelement("Descriptions", 
               xmlagg(
                  xmlforest(description as "Desc")
           ) as clob indent
           ) as t   
          from test_table;Then i removed the xmlagg function from the above select query and used xmlelement instead
      select
            XMLSerialize(document
            xmlelement("root",
             xmlagg(
               xmlelement("emp"          
               , xmlforest(Key as "ID")          
               , xmlforest(name as "ename")
               , xmlelement("Descriptions",            
                  xmlforest(description as "Desc")
           ) as clob indent
           ) as t   
          from test_table;This is working fine, but xml created with empty elements for Descriptions element for key 3 and 4 which has null values. I need don't need Descriptions element in the xml when it has null value. Please help me to resolve this.

    You can do it with a correlated subquery :
    SQL> select xmlserialize(document
      2           xmlelement("root",
      3             xmlagg(
      4               xmlelement("emp"
      5               , xmlforest(
      6                   t.key as "ID"
      7                 , t.name as "ename"
      8                 , (
      9                     select xmlagg(
    10                              xmlelement("Desc", d.description)
    11                              order by d.description -- if necessary
    12                            )
    13                     from test_desc d
    14                     where d.key = t.key
    15                   ) as "Descriptions"
    16                 )
    17               )
    18             )
    19           ) as clob indent
    20         )
    21  from test_table t;
    XMLSERIALIZE(DOCUMENTXMLELEMEN
    <root>
      <emp>
        <ID>1</ID>
        <ename>sam</ename>
        <Descriptions>
          <Desc>desc1_1</Desc>
          <Desc>desc1_2</Desc>
          <Desc>desc1_3</Desc>
        </Descriptions>
      </emp>
      <emp>
        <ID>2</ID>
        <ename>max</ename>
        <Descriptions>
          <Desc>desc2_1</Desc>
          <Desc>desc2_2</Desc>
          <Desc>desc2_3</Desc>
        </Descriptions>
      </emp>
      <emp>
        <ID>3</ID>
        <ename>peter</ename>
      </emp>
      <emp>
        <ID>4</ID>
        <ename>andrew</ename>
      </emp>
    </root>
    Or an OUTER JOIN + GROUP-BY :
    select xmlserialize(document
             xmlelement("root",
               xmlagg(
                 xmlelement("emp"          
                 , xmlforest(
                     t.key as "ID"
                   , t.name as "ename"
                   , xmlagg(
                       xmlforest(d.description as "Desc")
                       order by d.description -- if necessary
                     ) as "Descriptions"
             ) as clob indent
    from test_table t
         left outer join test_desc d on d.key = t.key
    group by t.key
           , t.name
    ;Edited by: odie_63 on 11 juil. 2012 14:54 - added 2nd option

Maybe you are looking for

  • How to use Oracle objects in java code

    Hi all! I'm reading an xls and i need to fill me oracle objects with java code: OBJECT_NAME OBJECT_TYPE LETTURA_OBJ TYPE LETTURA_OBJ TYPE BODY In the past weeks i've been using both java code into oracle and oracle objects, but new i need to write th

  • [SOLVED] Thinkpad T61p fan

    How do I know if my fan is working like it should? I have cpu scaling, and "acpi -t" gives Battery 1: charged, 100%      Thermal 1: ok, 48.0 degrees C      Thermal 2: ok, 45.0 degrees C the temperatures look ok, but I'm not really doing much, and it'

  • DB Link Error !!!!!!!

    LKM Oracle to Oracle DB link - Error ( Jan 5 2009) It worked fine on the same day when it got some inputs frm this forum... !! Hi , My Source and Target databases are Oracle... Since my Source has around 2 million records.....it is taking too much of

  • How do we view videos on our Mac computer?  We keep getting the message, "Blocked plug-in".

    We have a Mac desktop computer.  We suddenly can't watch videos.  We keep getting the message, "Blocked plug-in".  Please help. Thank you

  • Disk full error, but not even close!!  Please help.

    I recently moved my I-Tunes music folder to an external hardrive on my network. Everything has been functioning great, but when I tried to make a purchase from the Itunes store today, I get the following message when trying to donload: **The disk you