Hi!
First of all I think jsqlparser is great!
I have a small issue, when referencing a table in another db. When I write something like:
select * from table1 a join otherdb..table2 b on a.id=b.id
It doesn't seem to like the two dots ".." in otherdb..table2.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm, this got me thinking and actually I found that sybase behaves a bit funny, hehe… see these examples:
SELECTcolumnFROMtable-- OKSELECTcolumnFROMschema.table-- OKSELECTcolumnFROMdatabase..table-- OK (using default schema, dbo, notice 2 dots)SELECTcolumnFROMdatabase.schema.table-- OKSELECTcolumnFROMdatabase..schema.table-- FAIL, use only 1 dot when specifying schema
I have not seen this syntax anywhere other than in Sybase SQL.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-03-14
hi thomasa-aloc,
i noticed that you'd marked OK next to SELECT column FROM database.schema.table
i am having a problem parsing that simply statement, i get an exception
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " "." ". "" at line 1, column 35.
do you have any suggestion on how to get the parser to parse this statement?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
The examples I gave was only to show others what syntax is actually allowed in Sybase in hope that someone would incorporate this into jsqlparser. You could patch it yourself if you need this. For a simple (bad practice) solution you could implement a preprocessor before using jsqlparser, where you replace 'database.schema.table' with something like 'databaseMYDOTschema.table' as 1 dot is valid syntax. Afterwards you could post process it and replace 'MYDOT' with '.'.
But the best thing would be to have it added to the grammar file, but it seems like there is not much work being done on the project these days :-(
~thomasa-aloc
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-03-15
thanks for the reply.
i was able to modify the grammar that was included with jsqlparser and added the extra field needed for database.schema.table
Hi!
First of all I think jsqlparser is great!
I have a small issue, when referencing a table in another db. When I write something like:
select * from table1 a join otherdb..table2 b on a.id=b.id
It doesn't seem to like the two dots ".." in otherdb..table2.
when the two dots syntax can be used? I've never seen it
Sybase syntax uses 2 dots for database references, as in:
Hmm, this got me thinking and actually I found that sybase behaves a bit funny, hehe… see these examples:
I have not seen this syntax anywhere other than in Sybase SQL.
hi thomasa-aloc,
i noticed that you'd marked OK next to SELECT column FROM database.schema.table
i am having a problem parsing that simply statement, i get an exception
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " "." ". "" at line 1, column 35.
do you have any suggestion on how to get the parser to parse this statement?
Hi
The examples I gave was only to show others what syntax is actually allowed in Sybase in hope that someone would incorporate this into jsqlparser. You could patch it yourself if you need this. For a simple (bad practice) solution you could implement a preprocessor before using jsqlparser, where you replace 'database.schema.table' with something like 'databaseMYDOTschema.table' as 1 dot is valid syntax. Afterwards you could post process it and replace 'MYDOT' with '.'.
But the best thing would be to have it added to the grammar file, but it seems like there is not much work being done on the project these days :-(
~thomasa-aloc
thanks for the reply.
i was able to modify the grammar that was included with jsqlparser and added the extra field needed for database.schema.table
Table Table():
{
Table table = null;
String name1 = null;
String name2 = null;
String name3 = null;
}
{
(LOOKAHEAD(5)
name1=RelObjectName() "." name2=RelObjectName() "." name3=RelObjectName() { table = new Table(name1, name2, name3); }
|
LOOKAHEAD(3)
name1=RelObjectName() "." name2=RelObjectName() { table = new Table(name1, name2); }
|
name1=RelObjectName() { table = new Table(null, name1); }
)
{
return table;
}
}
i then ran javacc to generate the new code…now i'm having trouble parsing case statements :(