db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Riedel <sa...@nurfuerspam.de>
Subject Using derby to parse an SQL statement
Date Wed, 12 Nov 2008 14:08:28 GMT
Hi there,

we are working on a small project where we need to analyze an SQL 
statement that can be of any kind: very simple, with inner selects, 
complex join etc.

We figured it inappropriate to start to write our own parser when there 
are other projects, like derby, out there that can do it much better 
than we would possibly do ... so this was our idea:

Can we use derby to create an instance of Parser 
(org.apache.derby.iapi.sql.compile.Parser.class) and let our SQL 
statement be parsed by calling the parse() method on this instance? What 
we want to have is a syntax tree of the statement that allows us to see 
which tables and which fields are accessed / included in the statement 
(including any possibly done "renames" รก la SELECT street AS "ADDRESS" 

The problem is, that we are stuck ... we spent several days now to try 
to find the proper way to create an instance of the Parser. Is it 
possible at all without having to set up a running derby system?

Is the Monitor class the right entry point? How can we create a 
CompilerContext so that a Parser instance can be created?

This sure is off-topic but we don't see any way through all this. Can 
you help us?

Thanks in advance


To reply to this posting directly use the following address and
remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net

View raw message