Hierarchy XML query question

I have a table in the form of:


A, B AND C 1 2 3
B 4 5 6 D
A C 7 8 9

I want my XML in the form
< name FOO = 'A' >
< BAR name = "B" >
< name ZEE 'C' = >
< x >/< x > 1
< Y > 2 / < y >
< Z > 3 < /z >
< / ZEE >
< name ZEE = "D >.
< x > 4 / < x >
< Y > 5 / < y >
< Z > 6 / < z >
< / ZEE >
< / BAR >
< BAR name = "C" >
< name ZEE = 'A' >
< x > 7 / < x >
< Y > 8 / < y >
< Z > 9 / < z >
< / ZEE >
< / BAR >
< / FOO >

Is such a thing possible via SQL directly or I have to do a sort of XSL transformation? Can someone tell me something that speaks of how this is done?

It should do so using bys group successive and enveloping the xml of lower level with parent elements.

with
-- Get the distinct data sets by domain, datacenter, resource.
res as(
select akdomain, datacenter, akresource,
       xmlagg(
         xmlforest(currentload as "currentload", targetload as "targetload", capacity as "capacity")
       ) x
from   clusterload2
group by akdomain, datacenter, akresource
),
-- Consolidate the resources by domain, datacenter.
dc as(
select akdomain, datacenter,
       xmlagg(
         xmlelement("resource",xmlattributes(akresource "name"),x)
       ) x
from res
group by akdomain, datacenter
),
-- Consolidate the datacenters by domain.
domain as(
select akdomain,
       xmlagg(
         xmlelement("datacenter",xmlattributes(datacenter "name"),x)
       ) x
from   dc
group by akdomain
)
-- Wrap the xml with a domain.
select xmlelement("load-object",xmlattributes(akdomain "domain"),x) x
from   domain
/

Product:


  
    
      123
      124
      125
    
  
  
    
      223
      224
      225
    
    
      1
      1
      1
    
  

Tags: Oracle Development

Similar Questions

  • OAG - insert timestamps in XML query

    Hello

    I need to insert timestamps in XML query. Please suggest steps/options/filters to do?

    for example

    XML request:

    < xml >

    < timestamp > < / timestamp >

    < / xml >

    output must be

    < xml >

    < timestamp > 2006 - 05 - 04T 18: 13:51.0Z < / timestamp >

    < / xml >

    Kind regards

    Ganesh

    Hello

    You want to use the filter to add an XML node.

    Create a JavaScript filter, first to do something like this:

    function invoke (msg)

    {

    now = new Date();

    Msg.put (elements "UTCTime", now.toUTCString ());

    Returns true;

    }

    In Add an XML node to the node content add:

    ${UTCTime elements}

  • Problem of XML query structure

    Hi experts,
    I am looking for help on the following XML query. I have a table (for example) organized as such:
    meas     data_element     
    ------- ------------------- 
    ABC     rate                   
    DEF     rate1                    
    DEF     rate2                    
    DEF     rate3                    
    GHI     rate                    
    JKL     rate1a            
    JKL     rate2b             
    I try to keep the column 'soul' as the attribute of the top-level node, with the "data_elements" as attributes of the children of the 'SOUL '.

    In short, I am looking for the following output, but well... keep coming up short.
    <meas id="ABC"> 
         <data_elements>
            <data_element id="rate">
                <rpt>false</rpt> 
             </data_element>
        </data_elements>
    </meas>
    <meas id="DEF">
         <data_elements>
              <data_element id="rate1">
                   <rpt>false</rpt>
              </data_element>
                     <data_element id="rate2">
                   <rpt>false</rpt> 
              </data_element>
              <data_element id="rate3">
                      <rpt>false</rpt> 
              </data_element>
         <data_elements>
    </meas>
    .....and so forth...
    I'm unable to get multiple lines of "data_element" under "data_elements" and the single "meas" a single node, any suggestions? My code keeps generating several lines. The crux of the rpt is a constant value of 'false '.
    Thank you

    You group and aggregate using XMLAgg:

    SQL> set long 5000
    SQL>
    SQL> with sample_data (meas, data_element) as (
      2    select 'ABC',     'rate'   from dual union all
      3    select 'DEF',     'rate1'      from dual union all
      4    select 'DEF',     'rate2'  from dual union all
      5    select 'DEF',     'rate3'  from dual union all
      6    select 'GHI',     'rate'   from dual union all
      7    select 'JKL',     'rate1a' from dual union all
      8    select 'JKL',     'rate2b' from dual
      9  )
     10  select xmlserialize(content
     11           xmlagg(
     12             xmlelement("meas",
     13               xmlattributes(meas as "id")
     14             , xmlelement("data_elements",
     15                 xmlagg(
     16                   xmlelement("data_element",
     17                     xmlattributes(data_element as "id")
     18                   , xmlelement("rpt", 'false')
     19                   )
     20                   order by data_element -- if necessary
     21                 )
     22               )
     23             )
     24           )
     25           indent
     26         ) as result
     27  from sample_data
     28  group by meas ;
    
    RESULT
    --------------------------------------------------------------------------------
    
      
        
          false
        
      
    
    
      
        
          false
        
        
          false
        
        
          false
        
      
    
    
      
        
          false
        
      
    
    
      
        
          false
        
        
          false
        
      
    
     
    
  • Recovery of OSB road Note Error Handler xml query

    Hi guys,.

    I don't know if there is a thread that has already been addressed, but I couldn't find anything.

    Here's the scenario. I created Proxy Service X (http transport protocol) that routes a message to Business Service Y. Business Service Y called myWebService that is deployed in a remote domain. I have intentionally to cancel the deployment of the EAR that contains myWebService in the remote domain. When the Business Service Y try to call myWebService she will appear in error, the following message:
    < con xmlns:con: fault = "http://www.bea.com/wli/sb/context" >
    < con: errorCode > BEA-380002 < / con: errorCode >
    < con: reason > not found < / con: reason >
    < con: location >
    < con: node > RouteNode1 < / con: node >
    pipeline response - < con: path > < / con: path >
    < / con: location >
    < / con: fault >

    Business Service Z is an independent service that is used to send messages to a queue. I have an route Error Handler node Proxy Service X using a legend Service to route messages to Business Service Z.

    Now in the Proxy Service X error of node Road Manager , I would like to recover the original xml query that was received by Proxy Service X and send it to a queue by making use of the previously mentioned Legend of Service that routes messages to Business Service Z whenever the BEA-380002 of error type occurs.

    When you look at the response of the legend of Service (by making use of reports), the item entering the http transport layer does not contain the xml request, but simply the metadata of the message. How can I get the original xml to the scenario above query?

    Kind regards
    Ophola...

    Add an action to assign the title of the action request routing Actions. Using yield action assign the $body (initial application of XML) in a var, for example bodyvar. Now in the route node error handler, you can get the original query in the variable $bodyvar

    Kind regards
    Anuj

  • XML PIVOT QUERY QUESTIONS

    I'm new to PIVOT queries.  I was making reference to the discussion that follows, but ran into a problem.  https://forums.Oracle.com/message/9393302

    When I added the XML to format data, I started to have NULL values rather than what I was looking for.

    WITH (AS PIVOT_DATA)

    SELECT * FROM)

    SELECT THE REGION, FCST_PERIOD, PRIME_PART, FINAL_FORECAST

    OF XYZ WHERE FCST_PERIOD > = last_day (trunc (sysdate)) + 1 and FCST_PERIOD < = last_day (add_months(sysdate,12)) AND PRIME_PART IN ('BLAH')

    )

    PIVOT XML (SUM (FINAL_FORECAST) FOR FCST_PERIOD IN (SELECT DISTINCT FCST_PERIOD OF XYZ))

    )

    SELECT PRIME_PART, REGION,

    EXTRACTVALUE(FCST_PERIOD_XML,'/PIVOTSET/ITEM[1]/COLUMN[2]') FCST_PERIOD1,

    EXTRACTVALUE(FCST_PERIOD_XML,'/PIVOTSET/ITEM[2]/COLUMN[2]') FCST_PERIOD2,

    EXTRACTVALUE(FCST_PERIOD_XML,'/PIVOTSET/ITEM[3]/COLUMN[2]') FCST_PERIOD3

    OF PIVOT_DATA;

    RESULTS IN:

    PRIME_PARTREGIONFCST_PERIOD1FCST_PERIOD2FCST_PERIOD3
    BLAMIDWEST(NULL)(NULL)(NULL)
    BLAWEST-NV(NULL)(NULL)(NULL)
    BLASOUTH-EAST(NULL)(NULL)(NULL)
    BLAWEST-CA(NULL)(NULL)(NULL)
    BLASOUTHWEST(NULL)(NULL)(NULL)
    BLAEAST(NULL)(NULL)(NULL)

    The second part of my question is how would I do a group when you use a pivot query.  When I finished, I've has several parts and would like to group by REGION.

    Thank you!

    Names of elements and attributes in XML are case-sensitive.

    Try with:

    EXTRACTVALUE (FCST_PERIOD_XML, ' / PivotSet/item [1] /column [2]') FCST_PERIOD1

    There is also a good chance that EXTRACTVALUE is frowned upon in your version. Instead, use XMLQuery or XMLTable.

    That being said, using XML PIVOT just to grind it later into a number known columns is pretty useless.

    The same can be achieved much more efficiently with regular PIVOT operator (and if necessary analytical function).

    Post some examples of data in the table of your database and your final result expected to get useful assistance.

  • PTC connector query questions

    I develop a connector and had some questions about the presentation of the petition. I tried to read the documentation and help, but saw no reference to these issues. I know that some of these things may not still have public API, but any help would be appreciated.

    (1) is it possible to disable the entry blank for a ComboBox and set one of the values? I am referring to when you click on the button '+' on a query and selecting a comboBox field. I tried the 'enableEmptyEntry' attribute but could do not seem to work.

    (2) is there a way to prevent several lines for the same domain? I'm trying to match a web interface that allows values separated by commas in certain areas and not others. Trying to decipher the intent of the user if they use multiple lines for the same field becomes confused.

    (3) is there a way to disable 'Match All' or 'match any '?

    Thank you

    After further review, the removal of the empty the box entry drop-down list on the query page is not possible.

    One feature that we've added in the last release to support the case where the user needs to find records with a null or empty value for this combobox field. For example, finding bugs without test status. We have generic for all drop-down list boxes.

    The 'enableEmptyEntry' attribute is intended to work with the attribute "emptyEntryValue" as a pair. The user can do something like this in def.xml:
    enableEmptyEntry = 'true '.
    "emptyEntryValue =""
    Our framework poster in the drop-down list instead of empty or the default value .

    We recorded a feature request for this for a future version. Currently, writer connector is not a way to customize our application page, including the MatchAll, MatchAny option.

  • the sql XML query report conversion - sound the alarm

    Hi all

    I have a custom report based on an sql query (method-sql * more) I need to convert this report in XML. I followed these steps
    I have generated the xml file by opening this request in the rdf generator (file > > generate > > xml)
    I open this XML file in word and do the rest of the treatment
    Copy the original simultaneous program (copy to option in set the window)
    changed the short name and the type of output as XML (the same method and executable retention)
    Add newly build it program at thr group asks even the original program in conc
    now, if I run this program it will show a warning when I checked the journal (Journal of the conc program manager administer) it displays following error
    > > caused by: oracle.xdo.parser.v2.XMLParseException: beginning of the element root waited.

    When I checked the XML code (from diagnostics) I was following the text by giving parameters
    > > whitespace is not allowed at this location. Error processing resource
    > > Semi colon character was expected. Error processing resource

    I checked the preview while I was preparing the model in word, it was a weather display data
    by giving the same parameters for which I generated the XML code, it shows the same warning in apps
    The log file also has the data...

    I use reports 6i, XML 5.6.2 and apps 11.5.10.2

    kindly help me to solve this

    Thanks in advance

    Shivdeep Singh

    first question - did you just change the output format of your concurrent request (with the executable, type SQL * more) in XML format and add a template to it?

    If this is the case, I'm not surprised, you get an error. You must ensure that you generate actual XML output. If you run the query and then click on the "Diagnostics" button, you will see a button saying 'display XML '. Click on this to see what you get. If you get an error, then it is not correct XML.

    This is the case, you have several options:

    1. create a data model and use it to create the XML file
    2 use the XML features in your query to generate XML (never tried so cannot guarantee this will work)
    3. use file rdf reports to generate the XML file
    4 generate the XML of PL/SQL file

    I suggest that you try option 2 first of all it should be pretty fast & easy to test, then use option 1 as the best solution if it does not work.

    Good luck!

  • Progressive, Question on the fields of dynamic/DocID/Query Question of profiling

    This may seem like a newb question but someone has a logical division of the BOM designation DocID?

    In the course, we are responsible to use DocID = 1 and DocID = 2, but when/why would you use DocID = 3 or higher?

    Any help would be greatly appreciated with the portion of dynamic fields/query string of the progressive profiling course.

    Thank you.

    The DocID is a complete example. You can actually assign the query string to be what you want. I recently use cmpID for the campaign ID, where I spent to map identity of the campaign and then sent the URL to redirect dynamically the campaign ID field. In my case, we worked with 10 different docs or goods, so we had to actually 10 unique codes. In this case we would have, for example cmpID = 483h76d; cmpID = 9j872hd, etc, etc. If you want to learn more about how you can use the query string values, see this post: how Progressive E10 profiling using the component of cloud - scroll down to step 6 and you'll see how to set up dynamic rules using query strings.

  • give if or for cases of xml query condition

    Hi all

    I have the query to generate xml below.

    I would like to add in weather conditions that's if or case.

    Suppose I want to give in employee tag provided

    If e.comm is not null and e.sal > 1000 then this tag set complete should not display other wise.

    for example:

    This tag a commission and salary is greater than 1000 so this will show other wise tag of < employee > full will not be displayed.

    < employee >

    < > 7839 EMPNO < / EMPNO >

    KING of < ENAME > < / ENAME >

    < SAL > 1300 < / SAL >

    < COMM > 100 < / COMM >

    < / employee >

    (SELECT XMLELEMENT

    "Ministry."

    XMLFOREST)

    d.DEPTNO AS "Deptno."

    (SELECT XMLAGG (XMLELEMENT)

    "Employee."

    XMLFOREST (e.empno,

    e.Ename,

    e.job,

    e.Mgr,

    e.HireDate,

    e.SAL,

    e.comm)

    ))

    FROM emp e

    WHERE e.deptno = d.deptno) "EmployeeList".

    )

    ). EXTRACT ("*") AS "departments".

    D DEPT

    WHERE d.deptno = 10;

    Please review.

    Use a CASE, nothing special to XML here statement:

    (SELECT XMLELEMENT

    "Ministry."

    XMLFOREST)

    d.DEPTNO AS "Deptno."

    (SELECT XMLAGG)

    -CASE WHEN e.comm is not null and e.sal > 1000 THEN

    XMLELEMENT)

    "Employee."

    XMLFOREST (e.empno,

    e.Ename,

    e.job,

    e.Mgr,

    e.HireDate,

    e.SAL,

    e.comm)

    )

    END

    )

    FROM emp e

    WHERE e.deptno = d.deptno) "EmployeeList".

    )

    ). EXTRACT ("*") AS "departments".

    D DEPT

    WHERE d.deptno = 10;

  • Hierarchical query question

    Hi all

    I'm working on the database version (please avoid comments like "you should upgrade to a newer version," it's not me):

    Select * from version of v$.

    BANNER

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

    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production

    PL/SQL Release 9.2.0.8.0 - Production

    CORE Production 9.2.0.8.0

    AMT for HP - UX: 9.2.0.8.0 - Production Version

    NLSRTL Version 9.2.0.8.0 - Production

    I have the following hierarchical data:

    with mydata (emp_id, mgr_id, RESP) as

    (

    Select 1, null, 'Y' from dual union all

    Select 2, 1, "n" of all the double union

    Select option 3, 2, "n" of all the double union

    Select 4, 1, 'Y' from dual union all

    Select 5, 4, the double "n" of all union

    Select 6, 5, 'Y' from dual union all

    Select 7, 6, the double "n" of all union

    Select 8, 1, the double "n" of all union

    Select 9, 8, the double "n" of all union

    Select 10, 9, "Y" of the double

    )

    Select emp_id, mgr_id, RESP

    of mydata

    connect mgr_id = emp_id prior

    Start by emp_id = 1;

    EMP_ID MGR_ID RESP

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

    1            Y

    2 1 N

    3 2 N

    4 1

    5 4 N

    6 5

    7 6 N

    8 1 N

    9 8 N

    10 9 Y

    10 selected lines.

    Each employee has a Manager (self or the following in the upper hierarchy with RESP = 'Y')

    The root must be always charged.

    To find who is responsible for a certain employee ID, I can run the following query:

    I... responsible e: emp_id = 7 is 6

    Select emp_id, mgr_id, RESP

    of mydata

    When resp = 'Y '.

    and rownum < = 1

    Connect prior mgr_id = emp_id

    Start by emp_id = 7;

    EMP_ID

    ----------

    6

    1 selected line.

    i.e.: head = emp_id is 1/9

    Select emp_id

    of mydata

    When resp = 'Y '.

    and rownum < = 1

    Connect prior mgr_id = emp_id

    Start by emp_id = 9;

    EMP_ID

    ----------

    1

    1 selected line.

    i.e.: Manager emp_id = 4 is auto

    Select emp_id

    of mydata

    When resp = 'Y '.

    and rownum < = 1

    Connect prior mgr_id = emp_id

    Start by emp_id = 4;

    EMP_ID

    ----------

    4

    1 selected line.

    What query is the fastest to get all employees to a certain level of responsibility?

    That is to say: all employees not responsible according to 1 should give:

    EMP_ID MGR_ID RESP

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

    2 1 N

    3 2 N

    8 1 N

    9 8 N



    Kind regards.

    Alberto

    Hi, Alberto.

    So, you want to quit looking more far down the tree when you come to a node with an RESP = 'Y', right?

    Just include an RESP = ' don't (or resp. <> 'Y' or NVL (RESP, 'Y' <> 'Y') in the CONNECT BY State, like this:)

    Select emp_id, mgr_id, RESP

    of mydata

    connect mgr_id = emp_id prior

    and RESP = "n"-* NEW *.

    Start by emp_id = 1;

  • need help on xml query.

    pls click here for an example of xml data
    http://pcls1.craftyclicks.co.UK/XML/RapidAddress?postcode=AA11AA
    I make the following query to retrieve the values of xml data
    Select x1.org, x1.org2, x1.org3, x1.org4, x1.org5 in the xml_data_tab x, xmltable ('/ CraftyResponse/address_data_paf_compact/path/delivery_point ' in passing x.xml_data)
    columns
    org varchar2 (500) 'organisation_name' path, org2 and varchar2 (500) 'building_number', org3 varchar2 (500) "building_name" path
    path of varchar2 (500) of the org4 "dependent_locality", org5 varchar2 (500) way 'city') x 1;
    This is the output...

    org4 and org5 is foul can guide me what I do in the script...

    SQL > /.

    ORG AND ORG2 TO ORG3 ORG4 ORG5
    ---------- -------------------- -------------------- -------------------- ----------
    THE BAKERY 1
    MOVIES R US 3
    FAMILY BUT 7
    DEAR

    BIG HOUSE
    17 LITTLE COTTAGE

    SQL > spool off









    Here is an example of xml code
    < CraftyResponse >
    < address_data_paf_compact >
    < thoroughfare_count > 1 < / thoroughfare_count >
    < artery >
    < delivery_point_count > 5 < / delivery_point_count >
    < delivery_point >
    < organisation_name > THE BAKERY < / organisation_name >
    < department_name / >
    < po_box_number / >
    < building_number > 1 < / building_number >
    < sub_building_name / >
    < building_name / >
    < udprn > 12345678 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name > MOVIES R US < / organisation_name >
    < department_name / >
    < po_box_number / >
    < building_number > 3 < / building_number >
    < sub_building_name / >
    < building_name / >
    < udprn > 12345679 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name > FAMILY BUTCHER < / organisation_name >
    < department_name / >
    < po_box_number / >
    < building_number > 7 < / building_number >
    < sub_building_name / >
    < building_name / >
    < udprn > 12345680 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name / >
    < department_name / >
    < po_box_number / >
    < building_number / >
    < sub_building_name / >
    < building_name > BIG HOUSE < / building_name >
    < udprn > 12345681 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name / >
    < department_name / >
    < po_box_number / >
    < building_number > 17 < / building_number >
    < sub_building_name / >
    < building_name > LITTLE COTTAGE < / building_name >
    < udprn > 12345682 < / udprn >
    < / delivery_point >
    < dependent_thoroughfare_name / >
    < dependent_thoroughfare_descriptor / >
    < thoroughfare_name > TOP < / thoroughfare_name >
    < thoroughfare_descriptor > STREET < / thoroughfare_descriptor >
    < / artery >
    < double_dependent_locality / >
    < dependent_locality > CRAFTY VALLEY < / dependent_locality >
    < City > BIG CITY < / City >
    < postal_county > COUNTY POSTAL < / postal_county >
    < traditional_county > COUNTY TRADITIONAL < / traditional_county >
    < ZipCode > AA1 1AA < / code >
    < / address_data_paf_compact >
    < / CraftyResponse >

    for example

    SQL> select x2.org
      2       , x2.org2
      3       , x2.org3
      4       , x1.org4
      5       , x1.org5
      6  from xmltable('/CraftyResponse/address_data_paf_compact'
      7         passing httpuritype('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode=AA11AA').getxml()
      8         columns org4 varchar2(20) path 'dependent_locality'
      9               , org5 varchar2(20) path 'town'
     10               , delivery_points xmltype path 'thoroughfare/delivery_point'
     11       ) x1
     12     , xmltable('/delivery_point'
     13         passing x1.delivery_points
     14         columns org  varchar2(20) path 'organisation_name'
     15               , org2 varchar2(20) path 'building_number'
     16               , org3 varchar2(20) path 'building_name'
     17       ) x2
     18  ;
    
    ORG                  ORG2                 ORG3                 ORG4                 ORG5
    -------------------- -------------------- -------------------- -------------------- --------------------
    THE BAKERY           1                                         CRAFTY VALLEY        BIG CITY
    FILMS R US           3                                         CRAFTY VALLEY        BIG CITY
    FAMILY BUTCHER       7                                         CRAFTY VALLEY        BIG CITY
                                              BIG HOUSE            CRAFTY VALLEY        BIG CITY
                         17                   LITTLE COTTAGE       CRAFTY VALLEY        BIG CITY
     
    
  • Query does not work on my iPad (was: media query question)

    I am a site for mobile/tablet/Office of coding and while my office and the iphone respond to the CSS, my ipad does not work. The changes that I do take the tablet in dreamweaver, but when they go live the ipad does not. Of course, my media query must be incorrect, but I can't understand the question. Any help is very appreciated.

    http://gbetza.mydomain.com/WebService2/test/KathrynFee/2014/profile.html

    Thank you.

    Yes.  It is inevitable because smart phones are getting bigger while tablets are smaller & more.  He's always going to be some crossover.   Think of it this way, when a Tablet is behaving as a mobile device, he takes over the mobile network.  When the shelf behaves more like a desktop computer, you need the layout of office.

    Similarly, a great smartphone in landscape mode is likely to resemble the layout of your tablet.

    See the FluidGrid example below:

    http://ALT-Web.com/FluidGrid/Fluid2.html

    Office = 4-col layout

    Tablet = 2-col layout

    Mobile = 1-col layout

    For purposes of illustration, I added a thick border of gold at the disposal of the Tablet only.

    / * Tablet Layout: 481px to 768px. Inherits the styles of: Mobile layout. */

    @media only screen and (min-width: 481px) and (max-width: 768px) {}

    .gridContainer {width: 92%; border: 16px solid gold}

    }

    Nancy O.

  • Hierarchical query question (2)

    -Oracle Database 11 g Enterprise Edition Release 11.1.0.6.0 - 64 bit Production

    I'm putting together the two hierarchies. The first is the Center and the center of each parent to the top. The second attribute for each lower level is centre and it all the way to the top. Two hierarchies are in the same TABLE. An attribute if there is a Center in the ParentAttribId COLUMN (Conversely, the id COLUMN in this TABLE may be Centers.) Ultimately, the data will be listed record by record, with all parents in the form of columns.

    The query hierarchy Center works. The parent column records effort will be later, I worry about it right now. What I am struggling with is how to reach to get id from the Center in the attribute hierarchy. The fragment of the query (in the second ETC) trying to recover Center.Id, who is not in the scope, because it is included in the START WITH clause. But how to include in the FROM clause (to bring it within the scope), when it has nothing to do with the hierarchy (other than the starting point).

    < PRE >
    WITH
    Center_List_Hierarchy
    AS
    (
    SELECT
    -List 4) of the hierarchy of each Center, the level and the id.
    --
    -Note: by definition, CONNECT_BY_ROOT ModelId == ModelId ==: model.
    -ModelId returned to not use: model (in the outer query).
    CONNECT_BY_ROOT Id Center_Root,
    Center_Level LEVEL,
    ModelId model,
    ID
    Of
    ADMINEPO. PP_Respcenter
    CONNECT
    (--3) for each Center, go to (and understand) top, identified by Id = ParentId.
    ModelId = ModelId PRIOR
    AND Id = ParentId PRIOR
    AND PREREQUISITE Id & lt; & gt; ParentId PRIOR
    START BY
    (ModelId, Id)     IN
    (
    SELECT
    Attribute.ModelId,
    Attribute.Id
    Of
    ADMINEPO. PP_Respcenter_Name Center_Name,
    ADMINEPO. Attribute PP_AT_RespCenter
    WHERE
    (1) for this model, find the id of the list attribute.
    Center_Name.ModelId =: model
    AND Center_Name.LangId =: Name_Type_Default
    AND UPPER (Center_Name.NAME) = "LIST of CENTER.
    (--2) get all the centres associated with the attribute.
    AND Attribute.ModelId = Center_Name.ModelId
    AND Attribute.ParentAttribId = Center_Name.Id
    )
    ),
    Attribute_Hierarchy
    AS
    (
    SELECT
    (--4) for this Center, get each attribute with its hierarchy.
    Center.Id Center,
    CONNECT_BY_ROOT Id Attribute_Root,
    Attribute_Level LEVEL,
    ModelId model,
    ID
    Of
    ADMINEPO. PP_Respcenter
    CONNECT
    (--3) for each attribute, go to (and understand) top, identified by Id = ParentId.
    ModelId = ModelId PRIOR
    AND Id = ParentId PRIOR
    AND PREREQUISITE Id & lt; & gt; ParentId PRIOR
    START BY
    (ModelId, Id)     IN
    (
    SELECT
    Attribute.ModelId,
    Attribute.ParentAttribId
    Of
    Center_List_Hierarchy Center
    ADMINEPO. Attribute PP_AT_RespCenter
    WHERE
    (1) limit to the low level of the centres.
    Center.Center_Level = 1
    (--2) get his attributes.
    AND Attribute.ModelId = Center.Model
    AND Attribute.Id = Center.Id
    )
    )
    < / PRE >

    Hello

    Sorry, I don't understand.

    Whenever you have a problem, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all the tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    If you can show your problem using tables commonly available, such as scott.emp or hr.employees (which contains hierarcies) so you don't have to display the sample data; just results and explanations.

    Brian Tkatch wrote:
    ... What I am struggling with is how to reach to get id from the Center in the attribute hierarchy. The fragment of the query (in the second ETC) trying to recover Center.Id, who is not in the scope, because it is included in the START WITH clause.

    Isn't this Attribute_Root below?


    ...     Attribute_Hierarchy
    AS
    (
    SELECT
    (--4) for this Center, get each attribute with its hierarchy.
    Center.Id Center,
    CONNECT_BY_ROOT Id Attribute_Root,
    Attribute_Level LEVEL,
    ModelId model,
    ID
    Of...

  • XML query returns empty when tags no data

    Hi all

    I have a problem that I can't solve.

    I have the following query:
     select
                xmlelement
                (
                   "users",
                   xmlagg
                   (
                      xmlelement
                      (
                         "user",
                         xmlelement
                         (
                            "username",
                            e.pin
                         ),
                         xmlagg
                         (
                            xmlelement
                            (
                               "details",
                               xmlforest
                               (
                                  e.password as "password"
                                 ,e.first_name as "forename"
                                 ,e.surname as "surname"
                                 ,'0' as "retired"
                                 ,e.email_address as "email"
                                 ,e.telephone_number as "phone"
                                 ,'No External Ref' as "externalRef"
                                 ,add_months(sysdate,+60) as "expiryDate"
                               )
                            )
                         )
                      )
                   )
                ) xml_out
             from   aqaost_examiners e
             group by e.pin;
    The query returns the XML code in the desired structure.

    But the problem I have is that when there is no data found by the query, I always get a single row returned by the following: < user > < / users >

    I tried so many things to try to have the query return nothing if there is no data available, but I can't do without something else goes wrong (to mess up the XML structure, etc.).

    Please is - can anyone help or point me in the right direction?

    I thank very you much in advance!

    Robin

    Hello

    Peter,

    This is the GROUP that does this.

    Actually no, the GROUP BY refers to the deepest XMLAgg and is required if e.pin is not unique.

    Let it out, and you also seem to have of many XMLAGG (?)

    That's assuming that e.pin is unique within the table (which is probably a fair assumption in this case).

    In fact, the behavior comes from the XMLAgg in the foreground:

    SQL> select xmlelement("users",
      2           xmlagg(
      3             xmlelement("user",
      4               xmlelement("username", e.empno)
      5             , xmlelement("details",
      6                 xmlforest(
      7                   e.ename as "name"
      8                 , e.job as "job"
      9                 )
     10               )
     11             )
     12           )
     13         ) xml_out
     14  from scott.emp e
     15  where 1 = 0
     16  ;
    
    XML_OUT
    -------------------------------------
    
     
    

    As with other global functions (such as SUM or AVG) adding a GROUP OF 'something' solves the problem:

    SQL> select xmlelement("users",
      2           xmlagg(
      3             xmlelement("user",
      4               xmlelement("username", e.empno)
      5             , xmlelement("details",
      6                 xmlforest(
      7                   e.ename as "name"
      8                 , e.job as "job"
      9                 )
     10               )
     11             )
     12           )
     13         ) xml_out
     14  from scott.emp e
     15  where 1 = 0
     16  group by null
     17  ;
    
    no rows selected
    

    Robin,
    So the more intimate XMLAgg is really necessary, you can use a subquery:

    select xmlelement("users", v.users)
    from (
      select xmlagg(
               xmlelement("user",
                 xmlelement("username", e.empno)
               , xmlagg(
                   xmlelement("details",
                     xmlforest(
                       e.ename as "name"
                     , e.job as "job"
                     )
                   )
                 )
               )
             ) as users
      from scott.emp e
      group by e.empno
    ) v
    where v.users is not null
    ;
    
  • hierarchy XML

    Hi all


    I have the hierarchy of models of XML like this:


    1 EventParentEvent
    1.1.MarketingGoals
    1.2.EventsEvent
    1.2.1.Eventsevent EventVenue

    in siebel, there is a column in a join 1.1 to 1.2.1.

    rtf, I want to display all the column 1.1 and some 1.2.1 in a table, how can I do this?
    Please share if you have some experience with this.


    rgrds,
    dityo

    Published by: user13655637 on April 27, 2011 22:01

    Send me the xml and RTF model at [email protected]. I'll take a look.

    Thank you
    BIPuser

Maybe you are looking for

  • Upgrade to Windows 10

    Hello I am trying to upgrade Windows 7 service Pack1 (64 bit) to Windows 10 running in Bootcamp on my Mac Mini 5 (end of 2014), with OSX 10.10.5. I've updated OSX to where I have a message that no update is available on the App Store, I also ran Appl

  • How to disable the recovery of the Web page

    Every time Firefox hangs and I try to reopen it, he always tries to retrieve the Web pages that I had opened. But this makes restart Firefox at least 4 x slower than usual and just wasting time for me. Can someone tell me please how to disable this f

  • Is there an extension that will show you the list drop down bookmarks in the location bar?

    I wish the menu drop-down arrow in the address bar to show my favorites instead of show what I typed recently. I use the menu drop-down to go to my most visited sites, so this would be the prefect. Is there an extension that will do this, or somethin

  • Satellite L30-10 X: how to create product recovery disc

    How to create a product recovery disc and use it to clean my computer so it was as if it was brand new, once again?

  • Replacement HARD drive questions

    So to make a long story short the Thinkvantage Toolbox thing reported a bad hard drive for about a month now. I get no other indicators of failure of emminet as bad sectors but didn't want to push the thing as its under warranty so I am in touch with