Need help using SQL parser [message #596393] |
Mon, 21 September 2009 08:57  |
Eclipse User |
|
|
|
Hi.
I'm using the sql parser provided into the DTP package.
I'm trying to do a very simple execise: get the table name from a sql code. This could be:
question: select attribute from mytable
answer: mytable
I suppose that i can get it using the QuerySelect.getFromClause method, but I don't know how to parse an statement and get the QuerySelect from it.
Can anyone help me?, thanks.
|
|
|
Re: Need help using SQL parser [message #596400 is a reply to message #596393] |
Mon, 21 September 2009 20:20  |
Eclipse User |
|
|
|
The answer partly depends on what kind of application you are creating.
If it is a Eclipse plugin application (that is, takes full advantage
of the Eclipse plugin environment) then I can send you some sample code.
If it's an RCP app. or a stand-alone Java app., then it will be more
difficult because of some plugin dependency issues.
Once you have the parser working, then you can use the "Helper" classes
in plugin org.eclipse.datatools.modelbase.sql.query to get whatever
information you need from the parsed query statement. For example,
"getTablesForStatement(QueryStatement stmt)" in the StatementHelper class.
aiquefernandez wrote:
> Hi.
>
> I'm using the sql parser provided into the DTP package.
>
> I'm trying to do a very simple execise: get the table name from a sql
> code. This could be:
>
> question: select attribute from mytable
> answer: mytable
>
> I suppose that i can get it using the QuerySelect.getFromClause method,
> but I don't know how to parse an statement and get the QuerySelect from it.
>
> Can anyone help me?, thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.09545 seconds