Re: question about SQL Parser



Hi,

Felipe Maribel wrote:
I have installed this application to parse SQL queries, but it doesn't
work with the query I try to, it is to say, the parser doesn't match the
query I send it. That is because my query has sentences like
'mydb.dbo.mytable'
The parser currently won't break on foo.bar syntax but (if I'm remembering correctly) can't handle foo.bar.baz, that wouldn't be too hard to add.
or "case when" in SELECT clause, etc. Besides the
Sorry, the parser does not handle CASE statements and they would not be easy to add (though patches and collaborators are always welcome).
queries I want to parse don't have always the reserved words in capital
letters.
Identifier case is insensitive - in other words it doesn't matter if the reserved words are in capital letters.

For Data Definition Language (DDL), you should check out SQL::Translator, it is much more complete for DDL. It doesn't, at least the last time I checked, handle Data Modification.

At the moment your best option may be wrapping the parsing in an eval and creating two output files - one of successfully parsed statements and one of statements that couldn't be parsed. (Though depending on what you are trying to do, this may not be useful)

You may also want to look at some non-Perl SQL parsers such as the one by Mimer. Sorry I can't be more helpful, good luck.

--
Jeff

P.S. Since this isn't strictly DBI, perhaps you should send your reply to me directly.

.



Relevant Pages

  • Re: Look ups with multiple parameters
    ... Yes, the query is defined with two parameters, that's why if i send one ... However, if i send two parameters, the parser finds an error as i said. ... Please check the definition of the lookup again. ... You may also consider using explicit casting of data types to e.g. a ...
    (microsoft.public.sqlserver.dts)
  • Re: "Order by" clause
    ... While there is no actual ambiguity, the parser is not so sure. ... explicitly as the first column and once again in the *. ... parser does not try to figure out the meaning of the query. ...
    (microsoft.public.sqlserver.mseq)
  • Re: Xml doc = dom.parseString(request.getReader());
    ... capitol case letter. ... "Query" would then be appropriate. ... Feel free to give allot of suggestions:) ... parser = DocumentBuilderFactory.newInstance.newDocumentBuilder ...
    (comp.lang.java.programmer)
  • Re: Different query plans for view and view definition statement
    ... A VIEW is handled two ways in SQL. ... into the query that uses it and then the parser and optimizer handle it ... as if the query had been written with a derived table. ... Trust in the optimizer, Luke. ...
    (comp.databases.ms-sqlserver)