Master-details query to XML file?

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

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

Similar Messages

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

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

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

  • Export a master-details tables to XML

    Hi, here is my requirement :
    I'm having a page which shows data from 4 views as master details and need to have a command button to export the all these master details data into an xml structured file predefined by a xsd. Would like to get some help , to finish this task using ADF components. Thanks in advance.

    Could any one suggest any documentation , or sample code or demo to export a master details data as a xml file using ADF BC. Thanks.

  • JSP Servlet and convert the result set of an SQL Query To XML file

    Hi all
    I have a problem to export my SQL query is resulty into an XML file I had fixed my servlet and JSP so that i can display all the records into my database and that the goal .Now I want to get the result set into JSP so that i can create an XML file from that result set from the jsp code.
    thisis my servlet which will call the jsp page and the jsp just behind it.
    //this is the servlet
    import java.io.*;
    import java.lang.reflect.Array;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import javax.sql.*;
    public *class *Campaign *extends *HttpServlet
    *private* *final* *static* Logger +log+ = Logger.+getLogger+(Campaign.*class*.getName());
    *private* *final* *static* String +DATASOURCE_NAME+ = "jdbc/SampleDB";
    *private* DataSource _dataSource;
    *public* *void* setDataSource(DataSource dataSource)
    _dataSource = dataSource;
    *public* DataSource getDataSource()
    *return* _dataSource;
    *public* *void* init()
    *throws* ServletException
    *if* (_dataSource == *null*) {
    *try* {
    Context env = (Context) *new* InitialContext().lookup("java:comp/env");
    _dataSource = (DataSource) env.lookup(+DATASOURCE_NAME+);
    *if* (_dataSource == *null*)
    *throw* *new* ServletException("`" + +DATASOURCE_NAME+ + "' is an unknown DataSource");
    } *catch* (NamingException e) {
    *throw* *new* ServletException(e);
    protected *void *doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    Connection conn = *null*;
    *try* {
    conn = getDataSource().getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select post_id,comments,postname from app.posts");
    // out.println("Le r&eacute;sultat :<br>");
    ArrayList <String> Lescomments= *new* ArrayList<String>();
    ArrayList <String> Lesidentifiant = *new* ArrayList<String>();
    ArrayList <String> Lesnoms = *new* ArrayList <String>();
    *while* (rs.next()) {
    Lescomments.add(rs.getString("comments"));
    request.setAttribute("comments",Lescomments);
    Lesidentifiant.add(rs.getString("post_id"));
    request.setAttribute("id",Lesidentifiant);
    Lesnoms.add(rs.getString("postname"));
    request.setAttribute("nom",Lesnoms);
    rs.close();
    stmt.close();
    *catch* (SQLException e) {
    *finally* {
    *try* {
    *if* (conn != *null*)
    conn.close();
    *catch* (SQLException e) {
    // les param&egrave;tres sont corrects - on envoie la page r&eacute;ponse
    getServletContext().getRequestDispatcher("/Campaign.jsp").forward(request,response);
    }///end of servlet
    }///this is the jsp page called
    <%@ page import="java.util.ArrayList" %>
    <%
    // on r&eacute;cup&egrave;re les donn&eacute;es
    ArrayList nom=(ArrayList)request.getAttribute("nom");
    ArrayList id=(ArrayList)request.getAttribute("id");
    ArrayList comments=(ArrayList) request.getAttribute("comments");
    %>
    <html>
    <head>
    <title></title>
    </head>
    <body>
    Liste des campagnes here i will create the xml file the problem is to display all rows
    <hr>
    <table>
    <tr>
    </tr>
    <tr>
    <td>Comment</td>
    <td>
    <%
    for( int i=0;i<comments.size();i++){
    out.print("<li>" + (String) comments.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>nom</td>
    <td>
    <%
    for( int i=0;i<nom.size();i++){
    out.print("<li>" + (String) nom.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>id</td>
    <td>
    <%
    for( int i=0;i<id.size();i++){
    out.print("<li>" + (String) id.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    </table>
    </body>
    </html>
    This is how i used to create an XML file in a JSP page only without JSP/SERVLET concept:
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%
    // Identify a carriage return character for each output line
    int iLf = 10;
    char cLf = (*char*)iLf;
    // Create a new empty binary file, which will content XML output
    File outputFile = *new* File("C:\\Users\\user\\workspace1\\demo\\WebContent\\YourFileName.xml");
    //outputFile.createNewFile();
    FileWriter outfile = *new* FileWriter(outputFile);
    // the header for XML file
    outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
    try {
    // Define connection string and make a connection to database
    Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/SAMPLE","app","app");
    Statement stat = conn.createStatement();
    // Create a recordset
    ResultSet rset = stat.executeQuery("Select * From posts");
    // Expecting at least one record
    *if*( !rset.next() ) {
    *throw* *new* IllegalArgumentException("No data found for the posts table");
    outfile.write("<Table>"+cLf);
    // Parse our recordset
    // Parse our recordset
    *while*(rset.next()) {
    outfile.write("<posts>"+cLf);
    outfile.write("<postname>" + rset.getString("postname") +"</postname>"+cLf);
    outfile.write("<comments>" + rset.getString("comments") +"</comments>"+cLf);
    outfile.write("</posts>"+cLf);
    outfile.write("</Table>"+cLf);
    // Everything must be closed
    rset.close();
    stat.close();
    conn.close();
    outfile.close();
    catch( Exception er ) {
    %>

    Please state your problem that you are having more clearly so we can help.
    I looked at your code I here are a few things you might consider:
    It looks like you are putting freely typed-in comments from end-users into an xml document.
    The problem with this is that the user may enter characters in his text that have special meaning
    to xml and will have to be escaped correctly. Some of these characters are less than character, greater than character and ampersand character.
    You may also have a similiar problem displaying them on your JSP page since there may be special characters that JSP has.
    You will have to read up on how to deal with these special characters (I dont remember what the rules are). I seem to recall
    if you use CDATA in your xml, you dont have to deal with those characters (I may be wrong).
    When you finish writing your code, test it by entering all keyboard characters to make sure they are processed, stored in the database,
    and re-displayed correctly.
    Also, it looks like you are putting business logic in your JSP page (creating an xml file).
    The JSP page is for displaying data ONLY and submitting back to a servlet. Put all your business logic in the servlet. Putting business logic in JSP is considered bad coding and will cause you many hours of headache trying to debug it. Also note: java scriptlets in a JSP page are only run when the JSP page is compiled into a servlet by java. It does not run after its compiled and therefore you cant call java functions after the JSP page is displayed to the client.

  • Master/Detail query problem

    I have two VO, masterVo and detailVo, which assoicated with a VL.
    I create a page to query the masterVo and show the result master data and related detail data.
    Can I add a query criteria to filter the detailVo?
    Now I can only set where clauses in masterVo, is it possible to set where clauses both in masterVo and detailVo?

    I don't use query region for my master/detail data query, because the query result is in hgrid region on the other page.
    So I use controller to send the query criteria into AM for query. In masterVoImpl.java, I combine query
    criteria to Where clauses to initiate query. I have one query criteria belong to detailVo attr, How can I put the detailVo criteria
    and masterVo query criteria at one query?
    Thanks a lot.
    Louis

  • Master Detail Query automatic query ..Urgent help

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

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

  • Urgent: how to query/index xml files to retrieve information belonging to a section?

    os: linux
    db: oracle 9iR2
    Hi,
    how can I extract -> only <- the matching entry information from within a xml file, that belongs to the result of a query?
    For example, given the following xml:
    <QualifierRecordSet>
    <QualifierRecord QualifierType = "1">
    <QualifierUI>Q000002</QualifierUI>
    <QualifierName>
    <String>test1</String>
    </QualifierName>
    <DateCreated>
    <Year>1973</Year>
    <Month>12</Month>
    <Day>27</Day>
    </DateCreated>
    </QualifierRecord>
    <QualifierRecord QualifierType = "1">
    <QualifierUI>Q000003</QualifierUI>
    <QualifierName>
    <String>test2</String>
    </QualifierName>
    <DateCreated>
    <Year>1975</Year>
    <Month>10</Month>
    <Day10</Day>
    </DateCreated>
    </QualifierRecord>
    <QualifierRecordSet>
    I would like to query for '/QualifierRecordSet/QualifierRecord/QualifierName[String = "test2"]' and retrieve ONLY the second 'QualifierRecord' - entry, i.e.:
    <QualifierRecord QualifierType = "1">
    <QualifierUI>Q000003</QualifierUI>
    <QualifierName>
    <String>test2</String>
    </QualifierName>
    <DateCreated>
    <Year>1975</Year>
    <Month>10</Month>
    <Day10</Day>
    </DateCreated>
    </QualifierRecord>
    ...but not the' id' or 'name' of the xml-document(I have only one document).
    Thanks for your help in advance.
    Best Regards,
    Dan

    extract() would do what you want. But your whole approach of only have 1 document makes no sense when working with an XML database. See my reply to the other post for more reasons.

  • Representing Master Detail in an XML tree

    I'm trying to generate an XML document that will correctly depict the Master Detail relationship of my data using XMLSQLUtility.
    Basically, I have a master table EMP that can have multiple detail records in the EMP_NOTES table. How do I use XMLSQLUtil or XMSSQLParser to represent this in an XML document. For example:
    <EMP EMP_ID="12030">
    <EMP_FNAME>JOHN</EMP_FNAME>
    <EMP_LNAME>SMITH</EMP_LNAME>
    <EMP_NOTES NOTE_ID="1" EMP_ID="12030">
    <NOTE_LEN>60</NOTE_LEN>
    <NOTE_TEXT>GENERAL NOTES1</NOTE_TEXT>
    </EMP_NOTES>
    <EMP_NOTES NOTE_ID="2" EMP_ID="12030">
    <NOTE_LEN>20</NOTE_LEN>
    <NOTE_TEXT>GENERAL NOTES2</NOTE_TEXT>
    </EMP_NOTES>
    </EMP>
    <EMP EMP_ID="234450">
    <EMP_FNAME>JANE</EMP_FNAME>
    <EMP_LNAME>DOE</EMP_LNAME>
    <EMP_NOTES NOTE_ID="1" EMP_ID="234450">
    <NOTE_LEN>60</NOTE_LEN>
    <NOTE_TEXT>GENERAL NOTES1</NOTE_TEXT>
    </EMP_NOTES>
    </EMP>
    Please note that I cannot use XMLSQL Servlet since this will not be a Web based application and will not be interfacing with a Web Server.
    Thanks in advance.
    N.

    Hi,
    I couple of things.
    When you say:
    <div spry:detailregion="dsGallery dsGallery1
    dsGallery2"> <img src="../Images/Pictures/{@path}"
    ><br/>
    {@desc} </div>
    </div>
    {@desc} refers to only the first data set listed in the
    detail region; in your case, 'dsGallery'.
    If you want the detail region to refer to other data sets,
    you have to write it like '{dsGallery2::@desc}'
    But you want that detail region {@desc} to refer to any of
    the data sets that you clicked on.
    To do that, we have a Shell Data Set. Rather than explaining,
    the sample shows you how it works:
    http://labs.adobe.com/technologies/spry/samples/data_region/DataSetShell_accordion.html
    Let us know if you have more questions:
    Don

  • LIKE operator is not working in SQL Query in XML file

    Hi Gurus,
    LIKE operator is not working in SQL query in XML template.
    I am creating a PDF report in ADF using Jdeveloper10g. The XML template is as follows
    <?xml version="1.0" encoding="WINDOWS-1252" ?>
    <dataTemplate name="catalogDataTemplate" description="Magazine
    Catalog" defaultPackage="" Version="1.0">
    <parameters>
    <parameter name="id" dataType="number" />
    <parameter name="ename" dataType="character" />
    </parameters>
    <dataQuery>
    <sqlStatement name="Q1">
    <![CDATA[
       SELECT ename, empno, job, mgr from EMP where deptno=:id and ename LIKE :ename || '%']]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="EmployeeInfo" source="Q1">
    <element name="EmployeeName" value="ename" />
    <element name="EMPNO" value="empno" />
    <element name="JOB" value="job"/>
    <element name="MANAGER" value="mgr" />
    </group>
    </dataStructure>
    </dataTemplate>
    if i pass the parameter value of :ename from UI, it doesn't filter. But if I give ename = :ename it retrieves the data. Can anyone help me why LIKE operator doesn't work here?
    Appreciate your help,
    Shyamal
    email: [email protected]

    Hi
    Well for a start, you are doing some very strange conversions there. For example...
    and to_char(a.msd, 'MM/DD/YYYY') != '11/11/2030'
    and to_char(a.msd, 'MM/DD/YYYY') != '10/10/2030'If a.msd is a date then you should e converting on the other side ie.
    and a.msd != TO_DATE('11/11/2030', 'MM/DD/YYYY')
    and a.msd != TO_DATE('10/10/2030', 'MM/DD/YYYY')Also, you may want to take into consideration nothing being input in :P2_ITEM_NUMBER like this...
    AND INSTR(a.item_number,NVL(:P2_ITEM_NUMBER,a.item_number)) > 0Is item number actually a number or char field? If it's a number, you want to explicitly convert it to a string for using INSTR like this...
    AND INSTR(TO_CHAR(a.item_number),NVL(TO_CHAR(:P2_ITEM_NUMBER),TO_CHAR(a.item_number))) > 0?
    Cheers
    Ben

  • Query multiple XML files

    Hi,
    Is there another way of making queries in multiple different XML files other than using XQuery?
    I use CremeVM for a CDC but it doesn't have desiredAssertionStatus() method in its Class.class so XQuery doesn't work.
    Another option to solve it will be to execute multiple XPath expressions but not a good solution I think.
    Any suggestions?

    Thanks Curt,
    just for others....  My Function for reading XML:-
    let XmlImportedFile = (FilePath, FileName) =>
    let
    Source = Folder.Files(FilePath),
    File = Source{[#"Folder Path"=FilePath,Name=FileName]}[Content],
    ImportedXML = Xml.Tables(File)
    in
    ImportedXML
    in
    XmlImportedFile
    then it's use to combine into a custom Column:-
    let
    Source = Folder.Files("C:\Users\Tim\Data\Education\Collect\XML files January 2014"),
    InsertedCustom = Table.AddColumn(Source, "XmlImportedFiles", each XmlImportedFile([Folder Path],[Name])),
    RemovedColumns = Table.RemoveColumns(InsertedCustom,{"Content", "Name", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}),
    #"Expand XmlImportedFiles" = Table.ExpandTableColumn(RemovedColumns, "XmlImportedFiles", {"Name", "Header", "School", "Pupils"}, {"XmlImportedFiles.Name", "XmlImportedFiles.Header", "XmlImportedFiles.School", "XmlImportedFiles.Pupils"})
    in
    #"Expand XmlImportedFiles"
    thanks again and great blog post :-)
    Thank you for you time folks!

  • Can we write query in xml file to get desired field?

    I have  XML script like  below  can I query this file and get returns like Name only  for instance similar to 'select top 5 name from [HumanResources].[Department] order by DepartmentID'
    Engineering
    Tool Design
    Sales
    Marketing
    Purchasing
    <HumanResources.Department DepartmentID="1" Name="Engineering" GroupName="Research and Development" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="2" Name="Tool Design" GroupName="Research and Development" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="3" Name="Sales" GroupName="Sales and Marketing" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="4" Name="Marketing" GroupName="Sales and Marketing" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="5" Name="Purchasing" GroupName="Inventory Management" ModifiedDate="2002-06-01T00:00:00" />

    DECLARE @xml xml='<HumanResources.Department DepartmentID="1" Name="Engineering" GroupName="Research and Development"
     ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="2" Name="Tool Design" 
    GroupName="Research and Development" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department 
    DepartmentID="3" Name="Sales" GroupName="Sales and Marketing" ModifiedDate="2002-06-01T00:00:00" />
    <HumanResources.Department DepartmentID="4" Name="Marketing" GroupName="Sales and Marketing" 
    ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="5" Name="Purchasing" 
    GroupName="Inventory Management" ModifiedDate="2002-06-01T00:00:00" />'
    SELECT T.Name.value('@Name', 'VARCHAR(50)') AS Name
    FROM @xml.nodes('HumanResources.Department')
     AS T(Name);
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Oracle ADF Master-Detail query

    Hi I am using Jdeveloper 11.1.1.3.0, whenever I create master(Form)-detail(Table) relationship on JSF/view, in page defination files of same under the bindings section I found the bindings as
    "*attributValue, action, tree*", but according to theory it should appear like "*attributValue,action, table*" so can anybody explain me why I am getting *'tree'* type binding insted of *'table'.*

    Hi,
    can you please elaborate a bit more on how do you expect to have attributValue, action, table instead of attributValue, action,tree ?
    According to the following documentation, you should be expecting a tree:
    http://docs.oracle.com/cd/E17904_01/web.1111/b31974/web_masterdetail.htm#BJEHGCFJ
    http://docs.oracle.com/cd/E17904_01/web.1111/b31974/web_tables_forms.htm#CJADDIEJ
    Can you please elaborate a bit more on your question?
    Regards,
    Dimitris.

  • Querying large XML files with WEBSERVICE()

    I am trying to use the function WEBSERVICE to query large chucks of data, without success
    Let's go with an example :
    =SERVICEWEB(http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2305"))
    This line works, and give me the following result :
    <?xml version='1.0' encoding='utf-8'?>
    <evec_api version="2.0" method="marketstat_xml">
          <marketstat><type id="2305">
              <buy><volume>125924386</volume><avg>2.09</avg><max>2.39</max><min>1.00</min><stddev>0.36</stddev><median>2.20</median><percentile>2.37</percentile></buy>
              <sell><volume>384731177</volume><avg>11.87</avg><max>30.01</max><min>3.40</min><stddev>8.34</stddev><median>3.82</median><percentile>3.80</percentile></sell>
              <all><volume>431842145</volume><avg>5.63</avg><max>20.01</max><min>0.57</min><stddev>3.92</stddev><median>3.83</median><percentile>1.57</percentile></all>
            </type></marketstat>
        </evec_api>
    This is exactly the same content as the webpage from the url used (http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2305)
    In my case, I am working with several typeid and I would like to send the server only one query instead of N queries (where N is the number of typeid I use)
    I am want to use this query :
    http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2073&typeid=2288&typeid=2286&typeid=2306&typeid=2309&typeid=2305&typeid=2311&typeid=2310&typeid=2308&typeid=2270&typeid=2287&typeid=2267&typeid=2307&typeid=2272&typeid=2268&typeid=2393&typeid=2396&typeid=3779&typeid=2401&typeid=2390&typeid=2397&typeid=2392&typeid=3683&typeid=2389&typeid=2399&typeid=2395&typeid=2398&typeid=9828&typeid=2400&typeid=3645&typeid=2329&typeid=3828&typeid=9836&typeid=9832&typeid=44&typeid=3693&typeid=15317&typeid=3725&typeid=3689&typeid=2327&typeid=9842&typeid=2463&typeid=2317&typeid=2321&typeid=3695&typeid=9830&typeid=3697&typeid=9838&typeid=2312&typeid=3691&typeid=2319&typeid=9840&typeid=3775&typeid=2328&typeid=2358&typeid=2345&typeid=2344&typeid=2367&typeid=17392&typeid=2348&typeid=9834&typeid=2366&typeid=2361&typeid=17898&typeid=2360&typeid=2354&typeid=2352&typeid=9846&typeid=9848&typeid=2351&typeid=2349&typeid=2346&typeid=12836&typeid=17136&typeid=28974&typeid=2375&typeid=2868&typeid=2869&typeid=2870&typeid=2871&typeid=2872&typeid=2875&typeid=2876
    When you go on
    the webpage you can see that all results are there. However I am getting in excel :
    #VALUE!
    I think Excel is not waiting enough to get all the data, deciding there is no answer and telling me "no correct values".
    How could I make this work within one request ?
    Thank you for any input
    Hello everyone,
    I am trying to use the function WEBSERVICE to query large chucks of data, without success
    Let's go with an example :
    =SERVICEWEB(http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2305"))
    This line works, and give me the following result :
    <?xml version='1.0' encoding='utf-8'?>
    <evec_api version="2.0" method="marketstat_xml">
          <marketstat><type id="2305">
              <buy><volume>125924386</volume><avg>2.09</avg><max>2.39</max><min>1.00</min><stddev>0.36</stddev><median>2.20</median><percentile>2.37</percentile></buy>
              <sell><volume>384731177</volume><avg>11.87</avg><max>30.01</max><min>3.40</min><stddev>8.34</stddev><median>3.82</median><percentile>3.80</percentile></sell>
              <all><volume>431842145</volume><avg>5.63</avg><max>20.01</max><min>0.57</min><stddev>3.92</stddev><median>3.83</median><percentile>1.57</percentile></all>
            </type></marketstat>
        </evec_api>
    This is exactly the same content as the webpage from the url used (http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2305)
    In my case, I am working with several typeid and I would like to send the server only one query instead of N queries (where N is the number of typeid I use)
    I am want to use this query :
    http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2073&typeid=2288&typeid=2286&typeid=2306&typeid=2309&typeid=2305&typeid=2311&typeid=2310&typeid=2308&typeid=2270&typeid=2287&typeid=2267&typeid=2307&typeid=2272&typeid=2268&typeid=2393&typeid=2396&typeid=3779&typeid=2401&typeid=2390&typeid=2397&typeid=2392&typeid=3683&typeid=2389&typeid=2399&typeid=2395&typeid=2398&typeid=9828&typeid=2400&typeid=3645&typeid=2329&typeid=3828&typeid=9836&typeid=9832&typeid=44&typeid=3693&typeid=15317&typeid=3725&typeid=3689&typeid=2327&typeid=9842&typeid=2463&typeid=2317&typeid=2321&typeid=3695&typeid=9830&typeid=3697&typeid=9838&typeid=2312&typeid=3691&typeid=2319&typeid=9840&typeid=3775&typeid=2328&typeid=2358&typeid=2345&typeid=2344&typeid=2367&typeid=17392&typeid=2348&typeid=9834&typeid=2366&typeid=2361&typeid=17898&typeid=2360&typeid=2354&typeid=2352&typeid=9846&typeid=9848&typeid=2351&typeid=2349&typeid=2346&typeid=12836&typeid=17136&typeid=28974&typeid=2375&typeid=2868&typeid=2869&typeid=2870&typeid=2871&typeid=2872&typeid=2875&typeid=2876
    When you go on
    the webpage you can see that all results are there. However I am getting in excel :
    #VALUE!
    I think Excel is not waiting enough to get all the data, deciding there is no answer and telling me "no correct values".
    How could I make this work within one request ?
    Thank you for any input
    =SERVICEWEB(http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2305"))
    =SERVICEWEB(http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2305"))
    This is exactly the same content as the webpage from the url used (http://api.eve-central.com/api/marketstat?&regionlimit=10000002&typeid=2305)
    In my case, I am working with several typeid and I would like to send the server only one query instead of N queries (where N is the number of typeid I use)
    I am want to use this query :

    What is your machine configuration ?
    The above 2 suggestions would help, but it does depend on how your software is written.
    Please post more info about your environment and object design.
    Chintan

  • Master-Detail Query

    Hi,
    I have parent and child tables and I need to get data in the following fashion. I'm using emp and dept tables for this example.
    DEPTNO DNAME LOCATION EMPNO ENAME SAL JOB COMM
    10 HQ NY 1111 TOM 3000 CLERK 5
    1112 TIM 5000 MGR 0
    20 ACT BOS 1113 LEE 4000 ADMIN 0
    30 OP LA NULL NULL NULL NULL NULL
    Where there are more than one child row, I don't ant my master columns to repeat.
    Thanks,
    Asha

    This is really a presentation issue. The proper approach would be to use the relevant settings in whichever client you are using to display the data. In sqlplus that would be BREAK...
    SQL> break on dname
    SQL> select d.dname
      2         , e.empno
      3         , e.ename
      4  from emp e, dept d
      5  where e.deptno = d.deptno
      6  order by d.deptno
      7  /
    DNAME               EMPNO ENAME
    ACCOUNTING           7782 BOEHMER
                         7839 SCHNEIDER
                         7934 KISHORE
    RESEARCH             7566 ROBERTSON
                         7902 GASPAROTTO
                         7876 KULASH
                         7369 CLARKE
                         7788 RIGBY
    SALES                7521 PADFIELD
                         7844 CAVE
                         7499 VAN WIJK
                         7900 HALL
                         7698 SPENCER
                         7654 BILLINGTON
    14 rows selected.
    SQL> Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Master-Detail query problem with composite key

    I have tested a MD form with EMP and DEPT tables and the MD query works okay.
    I have created two tables both with two fields EMP_ID and REPORT_DATE as a composite key. The problem I am having with the MD form is that it does not query back the results when I select the QUERY button. I have verified that the join is setup during the creation of the form.

    I have recreated the form and the MD query works fine.

Maybe you are looking for