Output query result in XML format

folks:
could anybody provide more information
about how to generate query result in
xml format? looks like DBXML is for demo only
and i have heard that PLSQL XML parser is the way to go; so far i have not found
a sample yet on how to actually
do the XML generation; if you know more
about it, please let me know; thanks in
advance.
Bill

Here are some sample apps that might interest you:
[list]
[*][url [URL=http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The]http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The XML Flight Finder
[*][url [URL=http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B]http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B with XML
[list]
Enjoy,
-rh

Similar Messages

  • Saving the query result in XML format

    Hi All,
    I have a requirement to save the result of a query in XML format on the application server. Can we do this?
    Best Rgds,
    James.

    You can explore the possibility of the execution of query with XMLA:
    Official documentation
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1d71d190-0201-0010-239a-8b96516bf372
    and a good Blog
    /people/prakash.darji/blog/2006/09/04/work-with-xmla-web-service-for-bi-data-in-external-applications
    The result will be an SOAP message (XML) but also the request could be a SOAP message you can investigate if simulate the request by BW client or server.
    Regards,
    Sergio

  • Returning query results in XML format

    Besides using custom tag library, does anyone know any methods or techniques that i can retrive the query results from database in XML format. for example, i have a table named student in database like this:
    StudentNo  Name   Gender  Degree
    123       Tony    male    B.Comp.Sci.
    456       Tom     male    B.Fiance
    343       Mary    female  B.Accountingso, if i have query select * from table student, i would get someting like the following:
    <row>
    <studentNo>123</studentNo>
    <name>Tony</name>
    <Gender>male</Gender>
    <Degree>B.Comp.Sci</Degree>
    </row>
    <row>
    <studentNo>456</studentNo>
    <name>Tom</name>
    <Gender>male</Gender>
    <Degree>B.Finace</Degree>
    </row>
    The reason i am asking for this is i need query results returned in XML format, so i can wrap XSLT tag around, and apply for HTML, WML, and XHTML template resprectively so i can display them on different terminals. any help is appreciated.

    I have this method in a ResultSetMapper class:
         * Return result sets as an XML stream, with root tag named
         * "results", one "result" tag per row, and "result" child tag
         * names equal to the column name
         * @param query result set
         * @param list of column names to include in the result map
         * @throws SQLException if the query fails
         * @throws JDOMException if the XML stream creation fails
        public static final Document toJDOM(ResultSet rs, List wantedColumnNames)
            throws SQLException, JDOMException
            Element rows         = new Element("results");
            int numWantedColumns = wantedColumnNames.size();
            while (rs.next())
                Element row = new Element("result");
                for (int i = 0; i < numWantedColumns; ++i)
                    String columnName   = (String)wantedColumnNames.get(i);
                    Object value = rs.getObject(columnName);
                    row.addContent(new Element(columnName).setText(value.toString()));
                rows.addContent(row);
            return new Document(rows);
        }It uses JDOM from www.jdom.org. - MOD

  • Broadcasting the precalculated query results in web format

    Hi Experts,
    We have a requirement  where we need to broadcast the precalculated query results in web format, we know that we can do this through workbook, but we want to do it in web format to avoid the limitations of the workbook like number of rows in workbook limited to 65000 etc.,
    We are using 3.x environment,
    please suggest that is this functionality can be achievable, if yes how?
    Thanks in advance,
    -Vinay

    Hi All, this problem was resolved.
    Thanks,
    vinay

  • Need the output of a query in given XML format

    I have a table as
    create table t_cases (case_id number, pros_seq number, case_lname varchar2(100),
    day_phone number, night_phone number, intl_phone number);
    where case_id and pros_seq is the compound primary key.
    The insert script to insert the data in the table is
    insert into t_cases values(1, 1, 'test', 12, 23, 34);
    insert into t_cases values(1, 2, 'test', 56, 67, 78);
    commit;
    Now from this table I need to query and fetch the data in the following xml format.
    &lt;case REPEATINGTYPE="PageList"&gt;
    &lt;rowdata REPEATINGINDEX="1"&gt;
    &lt;caseid&gt;1&lt;/caseid&gt;
    &lt;prosseq&gt;1&lt;/prosseq&gt;
    &lt;PhoneNumbers REPEATINGTYPE="PageList"&gt;
    &lt;rowdata REPEATINGINDEX="1"&gt;
    &lt;CountryCode&gt;12&lt;/CountryCode&gt;
    &lt;Type&gt;Day&lt;/Type&gt;
    &lt;/rowdata&gt;
    &lt;rowdata REPEATINGINDEX="2"&gt;
    &lt;CountryCode&gt;23&lt;/CountryCode&gt;
    &lt;Type&gt;Night&lt;/Type&gt;
    &lt;/rowdata&gt;
    &lt;rowdata REPEATINGINDEX="3"&gt;
    &lt;CountryCode&gt;34&lt;/CountryCode&gt;
    &lt;Type&gt;International&lt;/Type&gt;
    &lt;/rowdata&gt;
    &lt;/PhoneNumbers&gt;
    &lt;/rowdata&gt;
    &lt;rowdata REPEATINGINDEX="2"&gt;
    &lt;caseid&gt;1&lt;/caseid&gt;
    &lt;prosseq&gt;2&lt;/prosseq&gt;
    &lt;PhoneNumbers REPEATINGTYPE="PageList"&gt;
    &lt;rowdata REPEATINGINDEX="1"&gt;
    &lt;CountryCode&gt;56&lt;/CountryCode&gt;
    &lt;Type&gt;Day&lt;/Type&gt;
    &lt;/rowdata&gt;
    &lt;rowdata REPEATINGINDEX="2"&gt;
    &lt;CountryCode&gt;67&lt;/CountryCode&gt;
    &lt;Type&gt;Night&lt;/Type&gt;
    &lt;/rowdata&gt;
    &lt;rowdata REPEATINGINDEX="3"&gt;
    &lt;CountryCode&gt;78&lt;/CountryCode&gt;
    &lt;Type&gt;International&lt;/Type&gt;
    &lt;/rowdata&gt;
    &lt;/PhoneNumbers&gt;
    &lt;/rowdata&gt;
    &lt;/case&gt;
    Please let me know how to do this.

    Like this...
    select XMLELEMENT( "case", XMLATTRIBUTES ('PageList' as "RepeatingType")
                     ,xmlagg(
                              xmlelement("rowdata", xmlattributes(pros_seq as "RepeatingIndex")
                                        ,xmlelement("caseid", case_id)
                                        ,xmlelement("prosseq", pros_seq)
                                        ,xmlelement("PhoneNumbers", xmlattributes('PageList' as "RepeatingType")
                                                   ,xmlelement("rowdata", xmlattributes(1 as "RepeatingIndex")
                                                              ,xmlelement("CountryCode", day_phone)
                                                              ,xmlelement("Type", 'Day')
                                                   ,xmlelement("rowdata", xmlattributes(2 as "RepeatingIndex")
                                                              ,xmlelement("CountryCode", night_phone)
                                                              ,xmlelement("Type", 'Night')
                                                   ,xmlelement("rowdata", xmlattributes(3 as "RepeatingIndex")
                                                              ,xmlelement("CountryCode", intl_phone)
                                                              ,xmlelement("Type", 'International')
            as x
    from t_cases

  • Need output of a query in given xml format.

    I have a table as
    create table t_cases (case_id number, pros_seq number, case_lname varchar2(100),
    day_phone number, night_phone number, intl_phone number);
    where case_id and pros_seq is the compound primary key.
    The insert script to insert the data in the table is
    insert into t_cases values(1, 1, 'test', 12, 23, 34);
    insert into t_cases values(1, 2, 'test', 56, 67, 78);
    commit;
    Now from this table I need to query and fetch the data in the following xml format.
    <case REPEATINGTYPE="PageList">
         <rowdata REPEATINGINDEX="1">
              <caseid>1</caseid>
              <prosseq>1</prosseq>
              <PhoneNumbers REPEATINGTYPE="PageList">
              <rowdata REPEATINGINDEX="1">
                   <CountryCode>12</CountryCode>
                   <Type>Day</Type>
              </rowdata>
              <rowdata REPEATINGINDEX="2">
                   <CountryCode>23</CountryCode>
                   <Type>Night</Type>
              </rowdata>
              <rowdata REPEATINGINDEX="3">
                   <CountryCode>34</CountryCode>
                   <Type>International</Type>
              </rowdata>
              </PhoneNumbers>
         </rowdata>
         <rowdata REPEATINGINDEX="2">
              <caseid>1</caseid>
              <prosseq>2</prosseq>
              <PhoneNumbers REPEATINGTYPE="PageList">
              <rowdata REPEATINGINDEX="1">
                   <CountryCode>56</CountryCode>
                   <Type>Day</Type>
              </rowdata>
              <rowdata REPEATINGINDEX="2">
                   <CountryCode>67</CountryCode>
                   <Type>Night</Type>
              </rowdata>
              <rowdata REPEATINGINDEX="3">
                   <CountryCode>78</CountryCode>
                   <Type>International</Type>
              </rowdata>
              </PhoneNumbers>
         </rowdata>
    </case>
    Please let me know how to do this.

    Like this...
    select XMLELEMENT( "case", XMLATTRIBUTES ('PageList' as "RepeatingType")
                     ,xmlagg(
                              xmlelement("rowdata", xmlattributes(pros_seq as "RepeatingIndex")
                                        ,xmlelement("caseid", case_id)
                                        ,xmlelement("prosseq", pros_seq)
                                        ,xmlelement("PhoneNumbers", xmlattributes('PageList' as "RepeatingType")
                                                   ,xmlelement("rowdata", xmlattributes(1 as "RepeatingIndex")
                                                              ,xmlelement("CountryCode", day_phone)
                                                              ,xmlelement("Type", 'Day')
                                                   ,xmlelement("rowdata", xmlattributes(2 as "RepeatingIndex")
                                                              ,xmlelement("CountryCode", night_phone)
                                                              ,xmlelement("Type", 'Night')
                                                   ,xmlelement("rowdata", xmlattributes(3 as "RepeatingIndex")
                                                              ,xmlelement("CountryCode", intl_phone)
                                                              ,xmlelement("Type", 'International')
            as x
    from t_cases

  • Ps query results to xml using xml link function registry

    In People tools version 8.46 we need something like where the ps query result output is in the form of XML so that it can be used for external system. The catch I cannot use webservices. It is something like opening peoplesoft queires form excel using hyperlink but in this case we need xml. I looked at David Vandiver's Excel XML libraries which open the data in excel but is there something where the hyperlink output is xml using xml link function registry. I have capatured the data in rowset and now need to create mime type of xml to write the data
    thanks in advance
    vinn

    If I understand correctly, you want to use something like Microsoft Excel's web queries to get data from a PeopleSoft query in XML format. I have never done this before, but if I were to implement this, here is what I would do in PT 8.46:
    1. Create an unstructured message in app designer.
    2. Create a user that only has access to the queries you want to expose to Excel
    3. Write synchronous message handler PeopleCode to call SwitchUser to switch to a specific query user rather than the generic integration broker user and execute a query, returning the results in XML (see [Query.RunToRowsest|http://download.oracle.com/docs/cd/E13292_01/pt849pbr0/eng/psbooks/tpcr/htm/tpcr31.htm#d0e113933] for an example).
    4. Call the message through IB using the HTTP GET URL format as defined in PeopleBooks: [http://download.oracle.com/docs/cd/E13292_01/pt849pbr0/eng/psbooks/tibr/book.htm?File=tibr/htm/tibr33.htm#H4026|http://download.oracle.com/docs/cd/E13292_01/pt849pbr0/eng/psbooks/tibr/book.htm?File=tibr/htm/tibr33.htm#H4026].

  • How to send SQL query results to XML ?

    Hey Guys, I am querying a DB with huge amount of traffic. A user select a particular lot and then details of the lot will be displayed in the following page. My concern here is that it takes really LONG to retrieve back the results coz it has to requiry in the following JSP page.
    I was told to use XML to retrieve the dataset and store it. Hence, in the following query it will re-query only from the recordsets in the XML file (...Logically, should be faster rite ? ). Hence, how do parse my recordsets retrieved from the SQL query to an XML file ?
    Any sort of suggestion , help, reference would be deeply appreciated ..Thanks !

    <HTML>
    <BODY>
    <H1>Manufacturing Summary beta </H1><BR>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.text.*" %>
    <jsp:include page="/index.html" flush="true"/>
    <P><B>Returned result<B><BR>
    <B>Query String :</B><%=request.getParameter("date") %>
    <TABLE BORDER=1 cellpadding=0 cellspacing=0>
    <%!
    static double roundDouble(double toBeRounded, int fractionDigits)
    NumberFormat format = NumberFormat.getInstance();
    format.setMaximumFractionDigits(fractionDigits);
    String tempDouble = format.format(toBeRounded);
    return Double.parseDouble(tempDouble);
    %>
    <%
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@klmomnidb:1521:
    OMNIDB","omni","omni");
    Statement stmt = null;
    ResultSet rset = null;
    String S_date = new String();
    String temp = new String();
    String lot_id = new String();
    String result = new String();
    String SQL_String = new String();
    double yield;
    int bad_cnt;
    S_date = request.getParameter("date");
    lot_id = request.getParameter("lot_id");
    temp = request.getParameter("TST_TEMP");
    SQL_String = "SELECT LOT_ID, FLOW_ID, TST_TEMP, MODE_COD, RTST_COD, PART_CNT, GO
    OD_CNT, OPER_NAM, JOB_REV, PROC_ID, START_T, FACIL_ID, TSTR_TYP, NODE_NAM FROM L
    OT where START_T > TO_DATE('"+ S_date + "','MM/DD/YYYY') AND TST_TEMP <='" + tem
    p+"' order by START_T";
    out.println(SQL_String);
    stmt = conn.createStatement();
    rset = stmt.executeQuery (SQL_String);
    out.println("<TR>");
    out.println("<TD> Select Lot(s)</TD>");
    out.println("<TD>Flow </TD>");
    out.println("<TD>Temp </TD>");
    out.println("<TD>Test Mode </TD>");
    out.println("<TD>Retest</TD>");
    out.println("<TD>Total </TD>");
    out.println("<TD>Good</TD>");
    out.println("<TD>Bad</TD>");
    out.println("<TD>Yield </TD>");
    out.println("<TD>UserID</TD>");
    out.println("<TD>Program</TD>");
    out.println("<TD>Mask</TD>");
    out.println("<TD>Start Time </TD>");
    out.println("<TD>Loc </TD>");
    out.println("<TD>Tester</TD>");
    out.println("<TD>System </TD>");
    out.println("</TR>");
    if (! rset.next()) {
    result ="No records found matching seach criteria.";
    while (rset.next()) {
    bad_cnt = Integer.parseInt(rset.getString(6)) - Integer.parseInt(rset.getString(
    7));
    yield = (Double.parseDouble(rset.getString(7)) / Double.parseDouble(rset.getStri
    ng(6))) * 100;
    result= "<TR>";
    result = result + "<TD><a href=coolpage.jsp?LOT_ID=" + rset.getString(1)+ ">" +
    rset.getString(1) + "</A></TD>";
    result = result + "<TD>" + rset.getString(2) + "</TD>";
    result = result + "<TD>" + rset.getString(3) + "</TD>";
    result = result + "<TD>" + rset.getString(4) + "</TD>";
    result = result + "<TD>" + rset.getString(5) + "</TD>";
    result = result + "<TD>" + rset.getString(6) + "</TD>";
    result = result + "<TD>" + rset.getString(7) + "</TD>";
    result = result + "<TD>" + bad_cnt + "</TD>";
    result = result + "<TD>" + roundDouble(yield,2) + "% </TD>";
    result = result + "<TD>" + rset.getString(8) + "</TD>";
    result = result + "<TD>" + rset.getString(9) + "</TD>";
    result = result + "<TD>" + rset.getString(10) + "</TD>";
    result = result + "<TD>" + rset.getString(11) + "</TD>";
    result = result + "<TD>" + rset.getString(12) + "</TD>";
    result = result + "<TD>" + rset.getString(13) + "</TD>";
    result = result + "<TD>" + rset.getString(14) + "</TD>";
    result = result + "</TR>"; %>
    <%=result%>
    <% }
    rset.close();
    stmt.close();
    conn.close();
    %>
    <%=result%>
    </TABLE>
    </BODY>
    </HTML>

  • Download BW Query results in HTML format

    On a daily basis, I need to get BW query results exported to an HTML extract file on the BW server.  The HTML file will then be transferred to a Windows server for use in a dashboard view by a third party developed portal.  The query has an input variable for period.
    What is the best/simplest method for scheduling an existing BW query to run on a daily basis to produce an HTML  extract / download file to the BW server file system?
    We are currently on BW 7.01 SP6.  We just completed a technical upgrade from BW3.5, but did not do a functional upgrade.
    I have read through many postings but have been unable to find a solution.  I have reviewed RSCRM_BAPI u2013 no html format.
    Any help would be greatly appreciated.
    Thanks,
    Mark Norton

    Hello Mark...
    Amer is right. You can create a broadcast setting to daily sends your
    query as MHTML format.
    You can send to your e-mail but there is a possibility to save on KM and CM repository.
    There is a little explanation on the link below:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/5c6b686a-0901-0010-8aab-c4d0e5a093a7?quicklink=index&overridelayout=true
    To create a broadcast setting, open the query via Query Designer.
    Click "Query" -> "Publish" -> "BEx Broadcaster"
    While you are creating the broadcast, there is a "Output Format" option.
    There is MHTML.
    I hope you find this information useful.
    Thanks
    Edward

  • How to output query results directly to a file

    Hello,
    I'm new to this and i need to know how to output the results of a query directly to a file instead of it displaying on the screen and then outputting to a file in SQL Developer Version 2.1.0.63.
    Thanks in advance for any help!
    Edited by: user13036938 on Jun 16, 2010 7:24 AM
    Edited by: user13036938 on Jun 16, 2010 7:25 AM

    for a really basic spool:
    SPOOL [FILEPATH];
    SELECT [SOMETHING] FROM [SOMETABLE] WHERE [SOMECONDITION];
    SPOOL OFF;see also:
    http://www.oracle.com/technology/products/database/sql_developer/files/sql_worksheet_commands.html
    for a list of other useful SQLPlus commands supported by SQL Developer
    Edited by: Irian on 16-giu-2010 17.08

  • How to: SELECT statement returns the result in XML format.

    That's it... I want to execute a query that returns all rowset in XML format. How can I do it?
    Using Oracle 8.0 and up.
    Tnx.

    FOR XML is a proprietary Microsoft Hack... It is not supported by Oracle in any release. Oracle 9.2.x includes the SQLXML operators, which are part of the SQL:2003 standard and are the agreed upon (Mircosoft, IBM, Oracle etc) way of generating XML from relational data....
    See http://download-west.oracle.com/docs/cd/B12037_01/appdev.101/b10790/xdb03usg.htm#sthref251

  • How a SELECT statement can return the results in XML format

    That's it... I want to execute a query that returns all rowset in XML format. How can I do it?
    I have Oracle 9i
    Thanks
    Jaime

    9i, or 9iR2 ?. If 9i I would recommend upgrading to 9iR2 and then using the SQL/XML operators.

  • Output query result to a text file in ORACLE

    I Need a procedure for generating output query into text file in Oracle.
    for Example,
    A table called Tab1
    the columns are c1,c2,c3,c4,c5.
    I want to store the data in text file in...
    First row as a column name & then, appear the records in second row onwards...
    c1|c2|c3|c4|c5.
    Please kindly provide the solution for this ASAP.

    In case you are using Oracle 9i or higher you should better create a DIRECTORY rather then setting utl_file_dir,e.g.
    SQL> CREATE DIRECTORY log_dir AS '/appl/gl/log';
    SQL> GRANT READ ON DIRECTORY log_dir TO DBA; http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_file.htm#ARPLS069

  • Row query results to column format

    I have a table as follows:
    DT | SN | Type | Value
    1/1/15 1:15 | 1 | HID | 123
    1/1/15 1:15 | 1 | VAL | 456
    1/2/15 1:15 | 1 | HID | 123
    1/2/15 1:15 | 1 | VAL | 111
    1/4/15 1:15 | 2 | HID | 222
    1/4/15 1:15 | 2 | VAL | 233
    1/5/15 1:15 | 3 | HID | 333
    1/5/15 1:15 | 3 | VAL | 344
    How to I construct a query in the below format...
    DT | SN | HID | VAL
    1/1/15 1:15 | 1 | 123 | 456
    1/2/15 1:15 | 1 | 123 | 111
    1/4/15 1:15 | 2 | 222 | 233
    1/5/15 1:15 | 3 | 333 | 344

    Hi engrforever,
    Use a PIVOT to do it. Modified the date values here:
    Create TABLE #TEMP1
    (DT datetime NULL,
    SN int NULL,
    [Type] varchar(12) NULL,
    Value int NULL
    INSERT INTO #temp1(DT, SN,Type,Value) VALUES (GETDATE()-4,1,'HID',123),
    (GETDATE()-4,1,'VAL',456),
    (GETDATE()-3,1,'HID',123),
    (GETDATE()-3,1,'VAL',111),
    (GETDATE()-2,1,'HID',222),
    (GETDATE()-2,1,'VAL',233)
    SELECT * FROM
    (SELECT DT,SN, TYPE, Value FROM #temp1) DT
    PIVOT
    ( SUM (VALUE)
    FOR TYPE IN ([HID],[VAL])
    ) PT
    DROP TABLE #TEMP1

  • SQL Developer 4.0 EA3. query result in export format problem

    Query output in export format (insert, csv, xml,...) is not working in 4.0 EA3.
    Query executed as script (F5) does not display anything:
    select /*insert*/ * from dual;
    SQL Developer 3 displays the result correctly:
    REM INSERTING into dual
    SET DEFINE OFF;
    Insert into "dual" (DUMMY) values ('X');
    About
    Oracle SQL Developer 4.0.0.13
    Version 4.0.0.13
    Build MAIN-13.30
    IDE Version: 12.1.3.0.41.131007.2031
    Product ID: oracle.sqldeveloper
    Product Version: 12.2.0.13.30
    Version
    Component    Version
    =========    =======
    Oracle IDE    4.0.0.13.30
    Java(TM) Platform    1.7.0_07
    Versioning Support    4.0.0.13.30

    That's been fixed for the next release.

Maybe you are looking for