Solved

How to parse a PL/SQL string into XML?

Posted on 2001-08-01
5
276 Views
Last Modified: 2013-11-23
Can anybody tell me how to parse a PL/SQL statement in String into an XML object in Java?

Current I need to develop a GUI for PL/SQL syntax checking in my Java application before sending SQL to Oracle database engine.


Thanks in advance.

Thomas
0
Comment
Question by:ThomasLi
5 Comments
 
LVL 1

Accepted Solution

by:
lawrie earned 50 total points
ID: 6341323
Assumeing I understand your question correctly, I would suggest using JavaCC, which is a parser generator, and quite powerful. (Antlr is another Java based parser generator, but I don't know enough about that one)

You can get it freely at http://www.webgain.com/products/metamata/java_doc.html

A grammar for PL/SQL can be found at http://www.cobase.cs.ucla.edu/pub/javacc/

Hope this helps
0
 

Author Comment

by:ThomasLi
ID: 6342325
I have seen that Oracle.xml.query.OracleXMLQuery class has a constructor which accepts a JDBC connection and a String query, I wonder to know when the connection is used? Can I use a null? How to pull back the string query in XML object?
0
 
LVL 3

Expert Comment

by:graf27
ID: 6343489
With OracleXMLQuery, you get any ResultSet as XML-String ! You cannot use a null as connection. You cannot pull back the string query in XML-Object, you get the Result of the Query as XML-String. I dont know how important it is in your application to do a own syntax-check programmatically. Let do the hard work your database. Send any statement to the database. If the statement is wrong or any other errors occur, you get ther right error-messages.
0
 

Author Comment

by:ThomasLi
ID: 6344507
The problem is that I got some nonstandard queries for non-Oracle databases mixed with Oracle SQL in distributed query, I have to parse the query and dispatch subqueries into the right database engines. But I don't want to write a parser because it too time consuming. Anyway, if I can't pull out the parser from Oracle, I will use JavaCC, the parser generation tools, to generate one.



Thank you all for responses.
0
 
LVL 5

Expert Comment

by:lwinkenb
ID: 8895272
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept comment by Lawrie as answer.
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
lwinkenb
EE Cleanup Volunteer
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
enhance the following code 3 42
Why  'Host Connection unavailable/Socket Error #113 No route to host' 6 75
Java program running SQL query 5 48
Setup GlassFish 4 35
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

749 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