6

Just recently discovered the SQL Query Parser classes in the DTP project, and it looks like a great (and unique) project.

My problem is that I need to analyze and see if I can merge some pretty hairy SQL fragments that are used in a big system. I need a smart and capable parser so I can perform an accurate analysis and determine if I can join some of these fragments together to improve performance. I've already figured the analysis I need to perform; however, the parser as-is is not able to parse these fragments, because they use specific db2 OLAP functions (over(), partition by, etc.) so I need to include the db2 plugins to my code.

How is this done? I haven't been able to find the classes (org.eclipse.datatools.sqltools.parsers.sql.query.db2.*) anywhere, and I also have no idea how to register them (I'm trying to do it manually, but of course it cannot find the appropriate class.)

This is what I'm currently doing, which I know is wrong, but I haven't found documentation about it:

SQLQueryParserManagerProvider provider = SQLQueryParserManagerProvider
        .getInstance();

provider.registerParserManager(
        "org.eclipse.datatools.sqltools.parsers.sql.query.db2",
        "DB2 UDB", null, null);

SQLQueryParserManager parserManager = SQLQueryParserManagerProvider
        .getInstance().getParserManager("DB2 UDB", null);

Can you please point out how to get the adequate parser for parsing DB2?

Edit: Probably the right question is, how can I make sure the db2 specific provider is correctly registered? what's the right class name?

4

1 回答 1

1

签出名为 SQLWorkBench/J 源的项目。它们具有特定于 db 的 SQL 解析功能。

于 2013-04-04T14:43:24.917 回答