Solved

Third Party Java API, XML and Oracle PL/SQL

Posted on 2004-03-20
1
630 Views
Last Modified: 2008-03-10
I need some help.

I have a third party java API to search a Stock Database

An example of how I would do this is:

String query = "Light Bulb";
QueryBuilder builder = new QueryEngine("stockSearch");
org.jdom.Document searchResult = Builder.search(query);

The search results come back as an XML org.jdom.document
<products>
      <listitem row="0">
            <description>40w Light Bulb</Description>
            <price>1.99</price>
      </listitem>

      <listitem row="1">
            <description>60w Light Bulb</Description>
            <price>2.99</price>
      </list>
</products>
            

What i need to know is how to execute the api from PL/SQL
and get the result into a temporary table in oracle.

Table structure.

temp_row                  NUMBER(12)
temp_description      VARCHAR2(200)
temp_price                  NUMBER(12,2)

So? Do i need to get the third party API into that database with loadjava?
What is the PLSQL to be able to pass a search string?
And how do i get the resultant document in to the db.

Alternatively the resulting document can be generated with http

eg http://stockserver/stockServlet?query=Light%20Bulb
and returns the same xml document

Would that be simpler to execute in the database?

I know there is a lot, but all all help is appreciated
0
Comment
Question by:MartynThompson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
concon earned 125 total points
ID: 10647138
Hi MartynThompson,

In order to load the values from XML document to db you should parse the XML output.

there are two ways to perform this in oracle db.

1. you could use PL/SQL XML parser packages included in XDK(xml development kit) for oracle. but this is implemented as DOM parsing techniques and for large XML files it can give memory exception.

2. you could use JAVA XML parser for oracle. (this is also in XDK) these classes are implemented with SAX parser. you will write java codes and then by use of loadjava the codes must be loaded to oracle. after all you should create stored java procedures to call these methods. here is a simple java stored procedure creation :

    function xmlsax2java(pinfile varchar2,poutfile varchar2) return varchar2 as LANGUAGE JAVA
        NAME 'SAXsample.parseIntoText(java.lang.String,java.lang.String) return java.lang.String';

both of the parsers could take URL as input and parse the XML from URL.
    parse('http://stockserver/stockServlet?query=Light%20Bulb')

or maybe you would load your search code into db, and use the return XML dom document by assinging it to the XMLDOM object in PL/SQL XML parser.

if you use the first way it would be easier to insert the values from XML to table(because you are writing directly PL/SQL stored proc.) but parsing would be harder.

you can get more detailed information and examples from XDK main page.
http://otn.oracle.com/tech/xml/index.html

Regards.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question