xmlserialization grouping

Hi all

How to group values in xml serialization

my query
select xmlserialize(document
             xmlelement("l",
               xmlattributes(locale_code as "id", BASE_FLAG AS "b" , dbms_lob.substr(text) as "d")
             )
             as Nclob indent
           ) as row_data
   from wrk_catalog_rd_l ;
Returns something like this

1 < id l = 0 b = 0d = "abcd" / >
1 < id l = 0 b = 0d = "abcd" / >
2 < id l = 1 b = 1 d = "abcd" / >

but I need something like this...

1 < id l = 0 b = 0d = "abcd" / > < id l = 0 b = 0d = "abcd" / >
2 < id l = 1 b = 1 d = "abcd" / >

your help is appreciated... Thank you...
SQL> set long 5000
SQL>
SQL> select deptno
  2       , xmlserialize(content
  3           xmlagg(
  4             xmlelement("emp",
  5               xmlattributes(empno as "id", ename as "name")
  6             )
  7             order by empno
  8           )
  9           as clob indent
 10         )
 11  from scott.emp
 12  group by deptno ;

DEPTNO XMLSERIALIZE(CONTENTXMLAGG(XML
------ --------------------------------------------------------------------------------
    10 
       
       

    20 
       
       

    30 
       
       
       
       
       
 

Also notice the change in the DOCUMENT keyword contained in XMLSerialize. It lets you serialize XML fragments (not not only root).

Tags: Database

Similar Questions

  • grouping of XML

    looking for help generate xml. Thanks to all who can help. im sure I do something wrong with the group. This inner query must also generate in a clob, so that the final result is 1 plug clob so my finished result is a clob.

    It works fine when I do by itself

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

    SELECT

    XMLELEMENT

    (

    'OBJECT ',.

    XMLATTRIBUTES)

    b.OBJECT AS 'NAME '.

    ), XMLAGG

    (

    XMLELEMENT

    (

    "WELL,"

    XMLELEMENT

    (

    'NAME' PROPERTY

    ),

    XMLELEMENT

    (

    "DESCRIPTION", DESCRIPTION

    )

    )

    )

    )

    OF mysecondtable b

    GROUP BY b.OBJECT

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

    but when I paste this into my other request, that it will fail with this error.

    ORA-01427: einreihig subquery returns multiple rows

    ----

    SELECT

    xmlserialize

    (

    content

    (

    XMLELEMENT

    (

    "trials."

    XMLATTRIBUTES)

    SYSTIMESTAMP AS 'DATE'),

    XMLELEMENT ("FUNCTIONS",

    (select XMLAGG

    (

    XMLELEMENT

    (

    "FUNCTION."

    XMLELEMENT

    (

    "U_ID", a.U_ID

    ) ,

    XMLELEMENT

    (

    'Function_name', a.FUNC_NAME

    ) ,

    XMLELEMENT

    (

    'PATH', a.PATH

    ) ,

    XMLELEMENT

    (

    "INCLUDE", a.INCLUDE

    ) ,

    XMLELEMENT

    (

    'DESC', a.DESC

    ) ,

    XMLELEMENT

    (

    'EX', a.EX

    ) ,

    XMLELEMENT

    (

    'DOC', a.DOC

    ) ,

    XMLELEMENT

    (

    'STATUS', a.STATUS

    )  ,

    XMLELEMENT

    (

    "PROP."

    (

    SELECT

    XMLELEMENT

    (

    'OBJECT ',.

    XMLATTRIBUTES)

    b.OBJECT AS 'NAME '.

    ),

    XMLAGG)

    XMLELEMENT

    (

    "WELL,"

    XMLELEMENT

    (

    'NAME' PROPERTY

    ),

    XMLELEMENT

    (

    "DESCRIPTION", DESCRIPTION

    )

    )

    )

    )

    OF mysecondtable b

    WHERE b.R_ID = a.U_ID

    GROUP BY b.OBJECT

    )

    )

    )

    )

    OF myfirsttable one

    )

    )

    )

    )

    as CLOB

    ) testxml

    OF THE DOUBLE

    OK, so you must group these 4 rows in a single XML using XMLAgg fragment:

    ...

    XMLELEMENT

    (

    "PROP."

    (

    SELECT XMLAGG)

    XMLELEMENT

    (

    'OBJECT ',.

    XMLATTRIBUTES)

    b.OBJECT AS 'NAME '.

    )

    ...

  • Get back information XMLSERIALIZE in a variable of the APEX...

    ((Request Express 4.1.1.00.23 11 g)


    So, I have the following code:

    with test_table as)

    SELECT VM_REPORT_DATE, quantity, point VM_CORE unpivot)

    ITEM quantity in (VM_HOSTS_NUM, VM_NUMBER, VM_PHYS_MEM, VM_VIRT_MEM, VM_CPU_COUNT, VM_TOTAL_DISK, VM_PROVISIONED_DISK)

    () where VM_DCNAME = "bc_production")

    SELECT XMLSERIALIZE (CONTENT XMLELEMENT ("SERIES", xmlAttributes (under the name "option name"),

    XMLAGG (XMLElement ("point", xmlAttributes (VM_REPORT_DATE as "name", much like "y")))

    ()) as the Group test_table NOMINATIVE by point;

    Which returns successfully:

    NOMINATIVE CASE
    < SET name = "VM_CPU_COUNT" > < point name = "2013-10-29" y = '1312' > < / point of > < point name = "2013-10-23" y = "1308" > < / point > < / SERIES >
    < SERIES name = "VM_HOSTS_NUM" > < name of the = y '2013-10-29' = '20' > < / point > < point name = "2013-10-23" y = "22" > < / point > < / SERIES >
    < SET name = "VM_NUMBER" > < point name = "2013-10-29" y = "617" > < / point of > < point name = "2013-10-23" y = "616" > < / point > < / SERIES >
    < SERIES name = "VM_PHYS_MEM" > < name of the = y "2013-10-29" = "4727.59" > < / point > < point name = "2013-10-23" y = "5175.54" > < / point > < / SERIES >
    < SERIES name = "VM_PROVISIONED_DISK" > < name of the = y "2013-10-29" = "76307.65" > < / point > < point name = "2013-10-23" y = "75848.3" > < / point > < / SERIES >
    < SET name = "VM_TOTAL_DISK" > < = point name y "2013-10-29" = '95955' > < / point > < point name = "2013-10-23" y = "93793.75" > < / point > < / SERIES >
    < SERIES name = "VM_VIRT_MEM" > < name of the = y "2013-10-29" = "3751.98" > < / point > < point name = "2013-10-23" y = "3739.98" > < / point > < / SERIES >

    It will be the heart you need to define a variable of APEX of these data with DATA <>< / DATA > tags added around it.

    What I'm not sure how is back with a variable chart_series_data PLSQL.

    chart_series_data: = "< >". Chr (10);

    chart_series_data: = chart_series_data |  "WHAT I WENT BACK ON IT."

    chart_series_data: = chart_series_data | Chr (10) | "< / data > ';

    Thank you

    SoC

    Why not just do it in the query?

    with test_table as)

    Select vm_report_date, quantity, item

    of vm_core

    UNPIVOT)

    quantity of the item (vm_hosts_num, vm_number, vm_phys_mem, vm_virt_mem, vm_cpu_count, vm_total_disk, vm_provisioned_disk)

    ) where vm_dcname = 'bc_production. '

    )

    Select xmlserialize (document

    XmlElement ("DATA"

    xmlagg)

    XmlElement ("SERIES"

    xmlattributes (point "name")

    xmlagg)

    XmlElement ("point"

    xmlattributes)

    vm_report_date as 'name '.

    , quantity as "o".

    )

    )

    )

    )

    )

    )

    ) as XMLDATA

    from test_table

    Point group;

  • Instruction XMLSerialize and case

    Hi all

    I try to use case statement on choose like that

    SELECT

    xmlserialize (DOCUMENT

    XmlRoot (XMLELEMENT (kdpwdocument, XMLATTRIBUTES)

    "xxxxxxxx" AS NRDS,

    "xxxxxxxx" AS rcvr,

    'xxxxxxxx' AS 'xmlns '.

    "xxxxxxxx" AS "xmlns: xsi"

    "xxxxxxxx" AS "xsi: schemaLocation".

    ),

    CASE WHEN REPO_STATUS = 1 THEN

    XMLAGG)

    XMLELEMENT ("regio",

    XMLELEMENT ("Inf",

    XMLELEMENT ("Id",

    XmlElement("PmryId",'1111'),

    XmlElement("ScndryId",'1111')

    )

    )

    )

    )

    ON THE OTHER

    XMLAGG)

    XMLELEMENT ("regio",

    XMLELEMENT ("Inf",

    XMLELEMENT ("Id",

    XmlElement("PmryId",'0000'),

    XmlElement("ScndryId",'0000')

    )

    )

    )

    )

    END

    ) ,

    VERSION "1.0" encoding = "UTF - 8'

    () AS CLOB)

    REPO

    WHERE 1 = 1

    ;


    but I get the error message:

    00937 00000 - 'not a single-group function.


    No idea how I can change my query for results? When I use the repo_status group, I get two rows, but it's not a good result for me

    Solution:

    SELECT

    xmlserialize (DOCUMENT

    XmlRoot (XMLELEMENT (document, XMLATTRIBUTES)

    "xxxxxxxx" AS NRDS,

    "xxxxxxxx" AS rcvr,

    'xxxxxxxx' AS 'xmlns '.

    "xxxxxxxx" AS "xmlns: xsi"

    "xxxxxxxx" AS "xsi: schemaLocation".

    ),

    XMLAGG)

    CASE WHEN repo_status = 1 THEN

    XMLELEMENT ("regio",

    XMLELEMENT ("Inf",

    XMLELEMENT ("Id",

    XmlElement("PmryId",'1111'),

    XmlElement("ScndryId",'1111')

    )

    )

    )

    ON THE OTHER

    XMLELEMENT ("regio",

    XMLELEMENT ("Inf",

    XMLELEMENT ("Id",

    XmlElement("PmryId",'0000'),

    XmlElement("ScndryId",'0000')

    )

    )

    )

    END

    ) )

    VERSION "1.0" encoding = "UTF - 8'

    () AS CLOB)

    REPO

    WHERE 1 = 1

    ;

    RESULT:

    "

    0000

    0000

    1111

    1111

    "

  • groups nested without group xmlagg function

    I make groups nested without group xmlagg function when using the xmlagg inside another function xmlagg function. Find the structure and sample data in the table 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 of the select query above and utilisΘ xmlelement xmlagg function
      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;
    It works fine, but the created xml with empty elements for Descriptions key 3 and 4 that has null values. I need no need descriptions element in the xml file when it is set to null. Please help me solve this problem.

    Expected behavior, it is not a bug.

    The real question is why did you put XMLAgg in the first place?
    You can expect several DESCRIPTION by employee?

    If yes then please provide some examples of data to this situation.
    If not then a simple case statement should be enough:

    SQL> set long 1000
    SQL>
    SQL> select XMLSerialize(document
      2          xmlelement("root",
      3           xmlagg(
      4             xmlelement("emp"
      5             , xmlforest(Key as "ID")
      6             , xmlforest(name as "ename")
      7             , case when description is not null then
      8                xmlelement("Descriptions",
      9                  xmlforest(description as "Desc")
     10                )
     11               end
     12             )
     13           )
     14          ) as clob indent
     15         ) as t
     16  from test_table;
    
    T
    --------------------------------------------------------------------------------
    
      
        1
        sam
        
          desc1
        
      
      
        2
        max
        
          desc2
        
      
      
        3
        peter
      
      
        4
        andrew
      
    
     
    
  • When I send a mass text by enabling / disabling message group, then I turn on message group, suddenly became a group text responses?

    When I send a mass text by enabling / disabling message group, then I turn on message group, suddenly became a group text responses?

    I sometimes send jokes or notifications to multiple contacts.  After I mass text them by activating / deactivating iMessage and Group Messages, then I switch on iMessage and Group Messages - will people I sent a mass text message can see phone numbers and the responses of the other?

    I think it should not because after sending the text it comes just up on their phone as a text message you only, but I want to just make sure

    Thank you

    Hello Eddie7777,

    Thanks for your post. I understand that you wanted to confirm if a mass message will convert to a group message after activating again Group Messaging. I certainly understand wanting to send a mass text message without launching a group of crazy message where number of all is shared. I'll be more than happy to help clarify.

    I tested on my iPhone, and so my previous knowledge on the messages, I discovered some great information. When you send a mass text with disabled group messaging message, it sends the messages individually and these other people only get a text without your mass SMS numbers. When you have enabled messaging group once again, it won't change the message on their end, and if they say it will for you.

    Hope this helps explain things!

    Take care!

  • Show all members of the Group of developer tools?

    How can I view all of the current members of the developer tools group?

    Hello Michael,

    Unfortunately, it is quite difficult. Here are some solutions:

    http://superuser.com/questions/279891/list-all-members-of-a-group-Mac-OS-x

    https://jamfnation.jamfsoftware.com/discussion.html?ID=15503

  • How can I create a group through Outlook without the application Outlook email?

    How can I create a group by using Outlook without an application Outlook email?

    Sigmalambda wrote:

    How can I create a group by using Outlook without an application Outlook email?

    It is difficult to understand what you're trying to do. You can create a group and send an email to the group in any mail client. The recipients can use any e-mail provider or an e-mail client to receive e-mail. Please explain in more detail what you are trying to accomplish.

  • iMessages group Conversation does not go in DND

    I've just updated to iOS 10 on my iPhone more than 6 and a group conversation in the Messages that I sometimes put on DND now does not recognize that the conversation has been implemented within DND.  Messages continues to inform me about all messages from anyone in the group.  Is there any solution for this?

    Thank you

    Brent

    Have what troubleshooting you tried? Troubleshooting user steps include reboot, reset, restore from backup, restore to factory; tests after each stage.

    If you return in the message after the ignition of the DND, does always show as it is turned on?

  • I restored my iPhone 6 from an itunes backup, but my group chat contacts are changed

    So I backed up my iphone on itunes because I went to the apple store to solve a problem I had. After that that they had deleted everything on my phone, I went home and tried to restore it. All went well, all my contacts were saved, my pictures, etc. so I waited so he could complete the synchronization for my laptop. While I was checking my messages, I noticed that many of the cats from group I had, had shared some of my names of friends with other people on my contact list. I also saw that other people who were in the GM had their photo ID, but instead of their name, their phone numbers were posted. I rebooted my phone and hope so that it can be corrected, but it didn't, I also tried to add the people who did not appear in the newsgroup, but I have added to them, the person that they have been replaced by a show! If anyone can help me on how to solve this problem, it would be highly appreciated!

    Hello, arsmars!

    Thank you for using communities of Apple Support. Looks like your Contacts are not being very cooperative since you have restored your iPhone iOS 10 6. I know that I have not memorized a phone number in ages and would need this support as soon as possible. I'll be happy to help you.

    It seems that you use iCloud to synchronize contacts between devices. On your iPhone, go to settings > iCloud. Disable the Contacts, wait 5 seconds, then turn it back on and check your Messages and Contacts.  I have a link below if you are still having problems:

    Get help using iCloud Contacts, calendars, or reminders

    I wish you a great weekend!

  • IOS 10 Notifications: Please bring back ability to group by app notifications

    Please, please, please bring back the ability to group by app notifications...

    And why Apple consider it an improvement "," to take away our ability to choose how we sort our notifications in the first place? Not happy at all to this subject :-(. Some of us are _a_lot_ notifications, and also be able to group by app notifications means that we can then _clear_ notifications by app, as well (i.e. clear specific _types_ of the notifications at a time), which is VERY useful... With respect, this is a gross oversight on the part of Apple. I'm an ardent loyal fan, very long Apple products, but 'small', absurd decisions like this add up, making it more difficult and more difficult to justify is not something else.

    -Thank you!

    Apple is not read here.

    Submit your Apple asking this feature here:

    http://www.Apple.com/feedback

  • iOS 10 - auto bluetooth with contact group synchronization

    I have my iPhone 5s coupled to my car bluetooth hands-free system.

    With iOS 9 I was able to sync only certain groups of Contacts from iPhone. It was helpful that I have a number of groups in iPhone Contacts, including one specially created for syncing to my car.

    Since the update of my iPhone to iOS 10, I have that option in the bluetooth settings of the iPhone to check any combination of 'Favorite phone', "Phone Recents" or "All Contacts". None of them are useful for me as I want to synchronize with one of the original groups in Contacts.

    Help, please!

    Thank you.

    The same problem. A month ago I could synchronize specific groups with the phone book from my car. Now, the only option is "Contact".  Help!

  • add/delete a contact group message iOS 10

    Can't seem to find how to delete/add contact group message since the update to iOS on iPhone 10 6. Solutions?

    nessrez wrote:

    Can't seem to find how to delete/add contact group message since the update to iOS on iPhone 10 6. Solutions?

    Send a message from your iPhone, iPad or iPod touch - Apple Support Group

    This is possible with an imessage group all users using an Apple device.

    You can't do it for a group message MMS - mix Apple and not Apple device device.

  • iOS 10 - how to group by app notifications?

    I just downloaded and installed the new 10 iOS and the first thing I noticed that I want to change is the notifications. I would like to bring grouped by app once again, how I put them up on iOS 9. However, I can't find this option anywhere in the settings. Can someone please tell me how I can change this setting, or if it is no longer an option?

    Thank you in advance.

    You are right. The new Notification Center so difficult of our lives and our long

    Please Apple return the old function "sort by apps.

  • If I go buy Apple Watch nike, that I can use other groups like leather band?

    If I go buy Apple Watch nike, that I can use other groups like leather band?

    At this point, all we know is here:

    https://www.Apple.com/Apple-watch-Nike/

Maybe you are looking for