Solved

Third Party Java API, XML and Oracle PL/SQL

Posted on 2004-03-20
1
615 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 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now