Solved

Third Party Java API, XML and Oracle PL/SQL

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

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

895 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

13 Experts available now in Live!

Get 1:1 Help Now