Oracel 10gR2 XMLDB -- how to query in Java

I’ve some problems.
I’ve some search queries which are working on normal relation table, but I don’t know how it works on XMLDB (Oracle 10gR2)
Structure of XML file
My xml table structure will be :
Create table <tablename>
Person_Id number primary key,
Person_BankName varchar2,
DateOfEntry date,
Xmlcol xmltype
Xmlcol xmltype will be mapped to a schema for the below xml file.
XML File
<Person>
     <Information>
          <firstname>Suchendra</firstname>
          <lastname>Kumar</lastname>
          <middlename>Krishna</middlename>
     </Information>
     <Account>
          <accountno>12212</accountno>
          <balance>42323.89</balance>
          <opendate>12-03-2005</opendate>
     </Account>
     <Transaction>
          <transamount>1000</transamount>
          <balance>41323.89</balance>
          <trandate>14-03-2005</ trandate >
          <trantime>10:40:22</trantime>
     </ Transaction >
</Person>
SQL Queries Required
1.     Query to fetch the records whose transaction has been done from date 12-03-2001 to date 01-01-2005.
2.     Query to fetch the records whose lastname=”Kumar”
3.     Query to fetch the records whose transaction has been done from time 9:09:55 to time12:26:23.
4.     Query to fetch the records whose balance > 4000 and balance < 5000.
5.     Regular expression Search in XMLDB. Ex: searching for records whose firstname has ‘su*’ in it.
How to extract these result set values in java for XMLDB (JDBC)?
How to fetch these values from the result set?
Whether Prepared Statement, Execute Query are compatible in XMLDB
Can anyone help me in this..
Thanks in advance
Athar

Athar,
You have been busy! You posted this same question to the SQL forum and the XMLDB forum. I see you got some answers regarding the XML part, so I will try to help you with the JDBC part. Have a look at this example:
http://tinyurl.com/oemd7
Good Luck,
Avi.

Similar Messages

  • How to query in java for Oracle 10gr2 XMLDB

    Hi,
    I�ve some problems.
    I�ve some search queries which are working on normal relation table, but I don�t know how it works on XMLDB(Oracle 10gR2)
    Structure of XML file
    My xml table structure will be :
    Create table <tablename>
    Person_Id number primary key,
    Person_BankName varchar2,
    DateOfEntry date,
    Xmlcol xmltype
    Xmlcol xmltype will be mapped to a schema for the below xml file.
    XML File
    <Person>
         <Information>
              <firstname>Suchendra</firstname>
              <lastname>Kumar</lastname>
              <middlename>Krishna</middlename>
         </Information>
         <Account>
              <accountno>12212</accountno>
              <balance>42323.89</balance>
              <opendate>12-03-2005</opendate>
         </Account>
         <Transaction>
              <transamount>1000</transamount>
              <balance>41323.89</balance>
              <trandate>14-03-2005</ trandate >
              <trantime>10:40:22</trantime>
         </ Transaction >
    </Person>
    SQL Queries Required
    1.     Query to fetch the records whose transaction has been done from date 12-03-2001 to date 01-01-2005.
    2.     Query to fetch the records whose lastname= �*Kumar�
    3.     Query to fetch the records whose transaction has been done from time 9:09:55 to time12:26:23.
    4.     Query to fetch the records whose balance > 4000 and balance < 5000.
    5.     Regular expression Search in XMLDB. Ex: searching for records whose firstname has �su*� or �*ab� in it.
    How to extract these result set values in java for XMLDB (JDBC)?
    How to fetch these values from the result set?
    Whether Prepared Statement, Execute Query are compatible in XMLDB
    Can anyone help me in this..
    Thanks
    Athar

    Athar,
    You have been busy! You posted this same question to the SQL forum and the XMLDB forum. I see you got some answers regarding the XML part, so I will try to help you with the JDBC part. Have a look at this example:
    http://tinyurl.com/oemd7
    Good Luck,
    Avi.

  • How to use sql query in java ?

    i don't know how to use sql query in java code.
    who can give me some advice?
    thanks

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • How i can execute the sql query in java code

    I already have sql query in jave plateform i need to execute this code how i can do that. i have unix env and with oracle database. should i just run this query in my sqlplus. this file has extention .java. thanks

    you can create a project in JDeveloper add the java file to it, add the Oracle JDBC library to the project properties and then hit the run button.

  • How changing the criterion for an access query in java?

    Hi @ all
    I would like to change a criterion for an access-query in java. I know how to run a access-query in java. How can I change the criterion in my access query in java without running the query it selfs? Can anybody help me?
    Thx
    Dario

    I would like to change a criterion for an
    access-query in java. I know how to run a
    access-query in java. How can I change the criterion
    in my access query in java without running the query
    it selfs? Can anybody help me?
    You can't.
    The database processes the query and then returns the result to you. Thus to change the query you must run the query again.
    You can of course add code do do the same thing. But unless it is very simple it is going to take a lot of code and might even be slower than doing the database call.

  • How to copy the java concurren program in oracle application

    Hi All
    I am working in oracle Apps R12.
    In AP (Account Analysis Report) is registered as java concurrent Program.
    Now i need to customize this concurrent program and add two new column and two parameter in that.
    Could any one pls provide me the steps that how to copy the Java concurrent,and make a new customized program.
    Whether copying a java concurrent program is same as cp registered as oracle report.
    Thanks & Regards
    Srikkanth

    Hi Sir,
    Thanks for your reply.
    I have find the xml file form data definition and in that they have written Sql query and they have called a Package.
    And the i have also taken the class file from the path as mentioned.
    Now i need to customize this report by adding two parameter and i need to add two new column to display in the rtf.
    Can you pls tell me the steps to copy or how to customize this report.
    Regards
    Srikkanth

  • Binding parameter to SQL/xpath query using java/jdbc

    I'm trying to execute a query containing an xpath.
    The query looks like this:
    select * FROM table  t where t.column.existsNode('/RootElement[contains(SubElement, "someVal")]/SubElement')In java replacing the "someVal" with a bind parameter "?" will not work:
    PreparedStatement ps = c.prepareStatement("select * FROM table t where t.column.existsNode('/RootElement[contains(SubElement, ? )]/SubElement') = 1");
    ps.setString(1,"someVal");
    =EXCEPTIONOn this forum I found that you can also use '||:namedParam||'
    So the query in java would be executed like;
    PreparedStatement ps = c.prepareStatement("select * FROM table t where t.column.existsNode('/RootElement[contains(SubElement, '||:1||' )]/SubElement') = 1");
    ps.setString(1,"someVal");This seems to work (I have no idea what the '|| ||' construct does, I don't seem to find any info about it)
    HOWEVER, it seems that doing it this way the value being bound is NOT escaped.
    So, doing this will yield in an orcale SQL/xpath exception:
    ps.setString(1,"som'eVal");
    I've went to all the oracle xml manual stuff I could find, but nowhere do they address this.
    Any one an idea how I can bind the value and still have escaping ?
    Edited by: user5893566 on Nov 27, 2008 12:06 AM
    Edited by: user5893566 on Nov 27, 2008 12:15 AM

    Would you mind explain me what the replace actually does?The idea is like this:
    Let's start with a string like some'V"al and surround it by the concat function:
      '...concat("' || some'V"al || '") ....' {code}
    replace the inner (i.e. all) double quotes with +",''","+ to obtain '...concat("' || some'V",''"'',"al || '") ...' {code}
    So this concatenates three parts of the original string where the double quotes are now enclosed by two single quotes. The resulting string should look like
    {code} '...concat("some'V",''"'',"al") ...'i.e. first argument of concat is enclosed by double quotes, the second one by two single quotes and the third one again by double quotes.  This is just a rewritten form of our original string!.
    Now incorporate the whole thing in the xpath expression  as shown in my previous example and it should work ;)
    hth
    michael                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to query XML data stored in a CLOB column

    I don't know XMLDB, so I have a dumb question about querying XML data which is saved as CLOB in a table.
    I have a table (OLAP_AW_PRC), with a CLOB column - AW_XML_TMPL_VAL
    This column contains this xml data - [click here|http://www.nasar.net/aw.xml]
    Now I want to query the data using the xml tags - like returning the name of AW. This is where I am having trouble, how to query the data from AW_XML_TMPL_VAL clob column.
    The following query generates error:
    ORA-31011: XML parsing failed.
    ORA-19202: Error occurred in XML processing
    LPX-00229: input source is empty
    SELECT
    extractValue(value(x), '/AW/LongName') as "AWNAME"
    from
    OLAP_AW_PRC,
    table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
    where
    extractValue(value(x) , '/AW/Name') = 'OMCR4'
    - Nasar

    Mark,
    Thanks. This is exactly what I was looking for.
    After doing @Name in both places (SELECT and WHERE clause) it worked.
    Now I have one more question.
    There are multiple DIMENSION tags in my xml, and I want to see the NAME attribute values for all of those DIMENSIONs. The following query returns
    ORA-19025: EXTRACTVALUE returns value of only one node.
    Cause: Given XPath points to more than one node.
    Action: Rewrite the query so that exactly one node is returned.
    SELECT
    extractValue(value(x), '/AW/@Name') as "AW",
    extractValue(value(x), '/AW/Dimension/@Name') as "DIMENSIONS"
    from
    OLAP_AW_PRC,
    table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
    where
    extractValue(value(x) , '/AW/@Name') = 'OMCR4'

  • How do I install JAVA JVM, JServer and XDK in Oracle Express Ed database

    IF I query with SELECT COUNT(*) FROM all_objects WHERE object_type LIKE 'JAVA%'; I get a count of 0.
    I see no DBMS_JAVA package.
    How can I install JAVA JVM, JServer and XDK in the Oracle Express Edition database?
    I see no initjvm.sql, initxml.sql and xmlja.sql scripts. There are catjava.sql and catexf.sql scripts in the rdbms/admin folder.

    cssifah,
    Looks like you want this Web page:
    http://www.oracle.com/technology/products/database/xe/forum.html
    Good Luck,
    Avi.

  • How to invoke a Java Program from Oracle 10g?(uRGENT)

    Hello.
    I've a query, that i have a program, that basically retreives the records from the
    oracle table and then parser this information and then insert the values in corresponding database base tables. I want that, whenever the new program is inserted, a Trigger should fire and pass the most recently entered record to the Parser Program, means
    1) Firing a Trigge
    2)Storing the most latest data and pass it to the Parser PROGRAM
    Can someone tell me how to do this? How to invoke a Java Program from within the database? Please if anyone has examples provide me. Its very urgent and tell me what is the basic mechanism.
    Thankyou.
    Ben

    With Java Stored Procedures Java may be caleed from a database.
    http://www.oracle.com/technology/tech/java/jsp/index.html

  • How to compile a Java file

    Hi All,
    I am extending a seeded CO and when I try to compile it in JDev , it asks for many class files the seeded CO imports.
    I have copied all those imported files to my local system and when I try to compile , it still throws an error that some class files used by the classes imported in seeded CO are missing. Now this goes on and on. ( Seems entire server needs to be on my local system).
    Now I decided to port the custom CO to server and compile it there. Even this seems to be a hard task for me as the javac command is not working on the server. It throws following exception
    Exception in thread "main" java.lang.ClassFormatError: com.sun.tools.javac.main. Main (erroneous method access flags)......................................
    Pls suggest how to compile a java file , as downloading entire server classes is a herculean task for me.
    Thanks,
    Srikanth

    Hi Avajain & D.Ram ,
    Thanks for the reply.
    I have downloaded around 70 dependent class files to local system. Now the CO is getting compiled correctly.
    I am extending a region level controller in Payroll page where in I have to default the salary to a predefined value.
    This field is having a VO attribute to it. Now can I go ahead and set a value to the MessageTextInput or should I extend the VO to replace the desired value in the place of already queried value.
    Thanks,
    Srikanth

  • How to query an ordinary xml

    I have an xml and I want to query for a particular sub element within it. I can't find any help on this in any of the documentation. All I find is the getVariableData but it can only query on xml that is defined to have part names. How to query on an ordinary xml that doesn't have any part defined? For example I want to query for USERNAME in the xml:
    <ServiceBean_Header simpleType="false">
    <USERNAME>SYSADMIN</USERNAME>
    <PASSWORD>SYSADMIN</PASSWORD>
    <RESPONSIBILITY_NAME>System Administrator</RESPONSIBILITY_NAME>
    <RESPONSIBILITY_APPL_NAME>SYSADMIN</RESPONSIBILITY_APPL_NAME>
    <SECURITY_GROUP_NAME>STANDARD</SECURITY_GROUP_NAME>
    <NLS_LANGUAGE>AMERICAN</NLS_LANGUAGE>
    </ServiceBean_Header>

    If the DOM you have was produced using the Oracle XML Developers Kit (XDK) then you can issue XPath statements against it using "selectSingleNode" and "selectNodes".
    import java.io.FileReader;
    import oracle.xml.parser.v2.DOMParser;
    import oracle.xml.parser.v2.XMLDocument;
    import org.w3c.dom.Node;
    public class Test {
        public static void main(String[] args) throws Exception {
          FileReader reader = new FileReader("YOUR_XML.xml");
          DOMParser parser = new DOMParser();
          parser.parse(reader);
          XMLDocument xmlDocument = parser.getDocument();
          Node resultNode = xmlDocument.selectSingleNode("ServiceBean_Header/USERNAME/text()");
          System.out.println(resultNode.getNodeValue());
    }-Blaise

  • Db link Query in Java

    I 'm executing a sql query from Java. The sql has data from two different database and i'm using db link for the same.
    But my java program connects to only one database. So my program is throwing "connection description ofrm remote database not found" error.
    How can i change my java program which will solve this issue?

    GaneshJay wrote:
    I 'm executing a sql query from Java. The sql has data from two different database and i'm using db link for the same.
    But my java program connects to only one database. So my program is throwing "connection description ofrm remote database not found" error.
    How can i change my java program which will solve this issue?Doesn't sound like an application error, it's probably a database error. What happens if you execute the query in the database through a tool? (Query browser?)

  • I am unable to launch my illustrator 5.5 or 6. It is asking me to instal Java SE 6. When i go to the website it installs java 8. How do I get Java SE 6. to use my illustrator.

    I am unable to launch my illustrator 5.5 or 6. It is asking me to instal Java SE 6. When i go to the website it installs java 8. How do I get Java SE 6. to use my illustrator?

    Prompted to install Java SE 6 Runtime | Mac OS 10.9
    Mylenium

  • How to query opening balance for all customer or Vendor for an speci. date

    Hi,
    How to query opening balance for all customer or Vendor for an specific date?
    Example:
    put any date and query will show all customer/ Vendor  that date opening/current balance.
    Regards,
    Mizan

    Hi mizan700 ,
    Try this
    SELECT T0.[DocNum] As 'Doc No.', T0.[CardCode] As 'Customer Code',
    T0.[CardName] As 'Customer Name',(T0.[DocTotal]-T0.[PaidSys]) As 'O/S Balance'
    FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
    INNER JOIN OCRG T2 on T1.GroupCode = T2.GroupCode
    INNER JOIN INV1 T3 ON T0.DocEntry = T3.DocEntry
    WHERE T0.[DocStatus] ='O'
    AND
    (T0.[DocDate] >='[%0]' AND T0.[DocDate] <='[%1]')
    Regards:
    Balaji.S

Maybe you are looking for