Solved

How to parse a PL/SQL string into XML?

Posted on 2001-08-01
5
267 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.

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

18 Experts available now in Live!

Get 1:1 Help Now