Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Third Party Java API, XML and Oracle PL/SQL

Posted on 2004-03-20
1
Medium Priority
?
636 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
1 Comment
 
LVL 3

Accepted Solution

by:
concon earned 500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

963 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