[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [dtp-sqldevtools-dev] Problem parsing SQL generated using SQL Builder
|
Brian,
Thank you so much! I will try this as soon as I get a chance. Really appreciate your help!
Regards,
Artem
On Thu, Jan 7, 2010 at 10:18 PM, Brian Payton
<bpayton@xxxxxxxxxx> wrote:
Hi Artem,
If you are using the SQL Query Parser
directly, you need to make sure to configure it with the same identifier
delimiter character that was used by the SQL Query Builder. The SQL
Query Builder gets the delimiter from the DatabaseDefinition object associated
with the current connection. (For MySQL the delimiter is back-tick.).
The delimiter is passed to the Query parser using the SQLQuerySourceFormat
object. Here's some example code from the getSQLSourceFormat method
in the SQLDomainModel class in the Query Builder plugin:
// Configure
the source format object with the IdentifierQuoteString option
DatabaseDefinition dbDef
= this.getDatabaseDefinition();
if
(dbDef != null
&& dbDef.getIdentifierQuoteString() != null
&& dbDef.getIdentifierQuoteString().length() == 1){
sqlSourceFormat.setDelimitedIdentifierQuote(dbDef.getIdentifierQuoteString().charAt(0));
}
and the getParserManager method in the
SQLParserUtil class in the Query Builder pluign:
//
Create an instance of the ParserManager
parserManager = SQLQueryParserManagerProvider.getInstance().getParserManager(dbProduct,
dbVersion);
//
Use SQLQuerySourceFormat for the editorInput's dialect
SQLQuerySourceFormat
srcFormat = SQLParserUtil.getSqlSourceFormat(editorInput.getSQLStatementInfo().getSQLDialectInfo());
parserManager.setSourceFormat(srcFormat);
Regards,
Brian
Brian Payton
Eclipse DTP Project Lead
SQL Tools Development
IBM Silicon Valley Laboratory
Date:
12/18/2009 07:50 AM
Subject:
Re: [dtp-sqldevtools-dev]
Problem parsing SQL generated using SQL Builder
Sent by:
dtp-sqldevtools-dev-bounces@xxxxxxxxxxx
Brian,
I was connected to MySQL and EN_US locale.
Best,
Artem
On Wed, Dec 16, 2009 at 3:40 PM, Brian Payton <bpayton@xxxxxxxxxx>
wrote:
Hi Artem,
This is odd. The SQLQuerySourceWriter class (in plugin org.eclipse.datatools.modelbase.sql.query),
which is what generates SQL from the Query model that underlies the SQL
Query Builder, is actually hard-coded to generate double-quote characters
for delimited identifiers.
What database type are you connected to? What is your locale setting?
Regards,
Brian
Brian Payton
SQL and XML Query Tools Development
IBM Silicon Valley Laboratory
(408) 463-2989, T/L 8-543-2989
From: Artem
Portnoy <artem.portnoy.ibi@xxxxxxxxx>
To:
DTP SQL Development Tools project
development list <dtp-sqldevtools-dev@xxxxxxxxxxx>
Date: 12/14/2009
07:26 AM
Subject: Re:
[dtp-sqldevtools-dev] Problem parsing SQL generated using SQL
Builder
Sent by:
dtp-sqldevtools-dev-bounces@xxxxxxxxxxx
Hi Brian,
Yes, the query was generated using the SQL Query Buider which is why I
think it's a real issue. We are trying to incorporate SQL Query Builder
in one of our wizards and we'd like to be able to parse the query after
it's been created by the user using the SQL Query Builder. Currently we
have to clean up the query after it's been created by stripping off the
` (backtick) characters before passing it to SQL Query Parser. I find it
really strange that two tools (SQL Query Builder and SQL Parser) existing
in the same project (DTP) would not properly work with each other.
Regards,
Artem
On Fri, Dec 11, 2009 at 6:08 PM, Brian Payton <bpayton@xxxxxxxxxx>
wrote:
Hi Artem,
Was the query generated by the SQL Query Builder? What SQL dialect
are you using? The syntax rules used by the SQL Builder and the SQL
Query Parser are fairly generic. According to the ISO SQL standard,
delimited identifiers such as 'test' should be surrounded by double-quote
characters. So
SELECT ID AS ID_NEW, NAME AS NAME_NEW FROM "test".EMPLOYEES should
parse OK.
Regards,
Brian
Brian Payton
SQL and XML Query Tools Development
IBM Silicon Valley Laboratory
From: Artem
Portnoy <artem.portnoy.ibi@xxxxxxxxx>
To: dtp-sqldevtools-dev@xxxxxxxxxxx
Date: 12/11/2009
02:16 PM
Subject: [dtp-sqldevtools-dev]
Problem parsing SQL generated using SQL Builder
Sent by: dtp-sqldevtools-dev-bounces@xxxxxxxxxxx
Hi,
I'm using SQLQueryParserManager to parse a select statement that was generated
using DTP's SQL Builder. I'm getting the following error when I parse
org.eclipse.datatools.sqltools.parsers.sql.SQLParserException: Unable to
parse the input: "SELECT ID AS ID_NEW, NAME AS NAME_NEW FROM `test`.EMPLOYEES;".
at org.eclipse.datatools.sqltools.parsers.sql.AbstractSQLParser.parser(AbstractSQLParser.java:414)
at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.makeAST(SQLParserManager.java:436)
at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.parse(SQLParserManager.java:791)
at org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager.parseQuery(SQLQueryParserManager.java:326)
...
Caused by: lpg.lpgjavaruntime.BadParseException
at lpg.lpgjavaruntime.BacktrackingParser.parse(BacktrackingParser.java:142)
at lpg.lpgjavaruntime.BacktrackingParser.parse(BacktrackingParser.java:100)
at org.eclipse.datatools.sqltools.parsers.sql.AbstractSQLParser.parser(AbstractSQLParser.java:384)
I believe the problem is caused by the presence of backticks in the statement.
The error goes away when I remove the backtick characters, which is the
workaround I'm currently using. This does seem to be a problem since usage
of backticks is valid in SQL.
Regards,
Artem Portnoy_______________________________________________
dtp-sqldevtools-dev mailing list
dtp-sqldevtools-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dtp-sqldevtools-dev
_______________________________________________
dtp-sqldevtools-dev mailing list
dtp-sqldevtools-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dtp-sqldevtools-dev
_______________________________________________
dtp-sqldevtools-dev mailing list
dtp-sqldevtools-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dtp-sqldevtools-dev
_______________________________________________
dtp-sqldevtools-dev mailing list
dtp-sqldevtools-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dtp-sqldevtools-dev
_______________________________________________
dtp-sqldevtools-dev mailing list
dtp-sqldevtools-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dtp-sqldevtools-dev
_______________________________________________
dtp-sqldevtools-dev mailing list
dtp-sqldevtools-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dtp-sqldevtools-dev